简体   繁体   中英

Redis Error condition on socket for SYNC: Connection refused

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 Inte.net, 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 ""

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

将此设置添加到从属<\/strong>redis.conf<\/strong>文件。

bind 0.0.0.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM