0

I'm using the django application where i want to run celery workers. But when i hit python -m celery -A cartpe worker, i get the following error

consumer: Cannot connect to redis://redis:6379/0: Error 8 connecting to redis:6379. nodename nor servname provided, or not known..

This is my celery.py file

import os
from celery import Celery

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cartpe.settings')

app = Celery('cartpe')

# Load the celery configuration from Django settings.
app.config_from_object('django.conf:settings', namespace='CELERY')

# Discover asynchronous tasks in Django app modules.
app.autodiscover_tasks()

__init__.py

from .celery import app as celery_app

__all__ = ('celery_app',)

settings.py

# Celery settings
CELERY_BROKER_URL = 'redis://redis:6379/0' # initially had 'redis://localhost:6379/0' which didn't work either
CELERY_RESULT_BACKEND = 'redis://redis:6379/0'

I have redis running in docker. Is this the reason i'm unable to connect to redis ? Also i'm using MacOs. I saw a number of solutions related to this but none worked. What can i do here to resolve the issue ?

1 Answer 1

0

The problem was with docker container where ports had be mentioned explicitly. docker run --name redis -d -p 6379:6379 redis:latest and restarted celery and it worked.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.