Shovarnu Dutta
Shovarnu Dutta

Reputation: 33

Unable to connect to redis server through docker-compose, I am using django_q framework as an async task queue and redis as broker

This is my docker-compose file configuration:

version: '3'

services:

redis:

image: redis:alpine

ports: - 6300:6379

db:

image: postgres:12.8-alpine
restart: always
volumes:
  - postgres_data:/var/lib/postgresql/data/
env_file:
  - ./.env.dev.db
ports:
  - 5400:5432

web:

build:
  context: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
  - .:/ps_survey
ports:
  - 8000:8000
env_file:
  - ./.env.dev
depends_on:
  - redis
  - db

django-q:

build: .
command: python manage.py qcluster
volumes:
  - .:/ps_survey
env_file:
  - ./.env.dev
ports:
  - 8001:8000
depends_on:
  - redis

volumes: postgres_data:

This is my qcluster configuration:

Q_CLUSTER = {

'name': 'ps_survey',
'workers': 4,
'recycle': 500,
'timeout': 60,
'compress': True,
'save_limit': 250,
'queue_limit': 500,
'cpu_affinity': 1,
'label': 'Django Q',
'redis': {
    'host': '127.0.0.1',
    'port': 6300,
    'db': 0,
}

}

This is exception I am receiving:

django-q_1 | connection.connect() django-q_1 | File "/usr/local/lib/python3.10/site-packages/redis/connection.py", line 563, in connect django-q_1 | raise ConnectionError(self._error_message(e)) django-q_1 | redis.exceptions.ConnectionError: Error 111 connecting to 127.0.0.1:6300. Connection refused.

Upvotes: 0

Views: 1780

Answers (1)

Shovarnu Dutta
Shovarnu Dutta

Reputation: 33

In qcluster configuration, change host to redis and port to 6379, in docker-compose file, under Redis service, change ports to 6379:6379.

Upvotes: 0

Related Questions