skip to Main Content

Using celery with redis in my django app
Everything was working fine until I ran into a problem. The location of the redis files was changed and redis could not access them. After searching, it turns out that this is due to random attacks on the Internet, and it is necessary to add confg
After I added the file, they both worked fine for a while, and then this problem appeared

1:S 25 Jun 2021 00:48:12.029 # Error condition on socket for SYNC: Connection refused
1:S 25 Jun 2021 00:48:12.901 * Connecting to MASTER 194.38.20.199:8886
1:S 25 Jun 2021 00:48:12.902 * MASTER <-> REPLICA sync started
1:S 25 Jun 2021 00:48:13.034 # Error condition on socket for SYNC: Connection refused
1:S 25 Jun 2021 00:48:13.907 * Connecting to MASTER 194.38.20.199:8886
1:S 25 Jun 2021 00:48:13.908 * MASTER <-> REPLICA sync started
1:S 25 Jun 2021 00:48:14.041 # Error condition on socket for SYNC: Connection refused

When I rebuild the Redis container it runs for a very short time and I get the same problem

settings.py

CELERY_BROKER_URL = os.environ.get("redis://redis:6379/0")
CELERY_RESULT_BACKEND = os.environ.get("redis://redis:6379/0")

docker-compose.yml

     redis:
      image: 'redis:alpine'
      restart: unless-stopped
      command: redis-server /usr/local/etc/redis/redis.conf
      volumes:
        - ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf
      ports:
        - '6379:6379'


  celery:
    restart: unless-stopped
    build:
      context: .
      dockerfile: ./docker/backend/Dockerfile_celery
    entrypoint: /app/docker/backend/celery-entrypoint.sh
    environment:
      - some env vars
    depends_on:
      - asgiserver
      - redis

redis.conf

    bind 0.0.0.0 
    protected-mode yes
    rename-command CONFIG ""

2

Answers


  1. Chosen as BEST ANSWER

    solved by change ports config with expose as Iain Shelvington mentioned above

       redis:
          image: 'redis:alpine'
          restart: unless-stopped
          command: redis-server /usr/local/etc/redis/redis.conf
          volumes:
            - ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf
          expose:
            - 6379
    

  2. Add this setting to slave redis.conf file.

    bind 0.0.0.0
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search