Error 111 connecting to localhost:6379. Connection refused. Django Heroku

后端 未结 12 1190
感动是毒
感动是毒 2020-12-28 12:33

I am able to run redis locally and everything works.

However when I deploy to heroku I get this error:

Error 111 connecting to localhost:6379. Conn         


        
12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-28 13:14

    if anyone comes here trying to get django_rq to work after encountering either 99 or 111 errors try the following:

    RQ_QUEUES = {
    "default": {
        "HOST": "redis",
        "PORT": "6379",
        "URL": os.getenv("REDISTOGO_URL", "redis://redis:6379"),  # If you're
        "DB": 0,
        "DEFAULT_TIMEOUT": 480,
      }
    }
    

    this requires you to name the redis container like this in your docker-compose.yml

    services:
      app:
        build:
          context: .
        ports:
          - "8000:8000"
        volumes:
          - ./app:/app
        command: >
          sh -c   "python manage.py makemigrations && 
                  python manage.py migrate && 
                  python manage.py runserver 0.0.0.0:8000"
        depends_on:
          - redis
      redis:
        image: redis:6-alpine
        ports:
          - "6379:6379"
    

提交回复
热议问题