[Django]-Django-celery: No result backend configured

7πŸ‘

I had the same problem while getting the result back from the celery task although the celery task was executed ( console logs). What i found was, i had the same setting CELERY_RESULT_BACKEND = "redis" in django settings.py but i had also instantiated celery in the tasks.py

celery = Celery('tasks', broker='redis://localhost') – which i suppose overrides the settings.py property and hence it was not configuring the backend server for my celery instance which is used to store the results.

i removed this and let django get celery get properties from settings.py and the sample code worked for me.

πŸ‘€psekar

4πŸ‘

If you’re just running the samples from http://www.celeryproject.org/tutorials/first-steps-with-celery/, you need to run the console via manage.py:

% python manage.py shell

πŸ‘€per06a

2πŸ‘

For those who are in a desperate search for a solution like I was.

Put this line at the end of the settings.py script:

djcelery.setup_loader()

Looks like django-celery is not going to consider it’s own settings without a strict order.

2πŸ‘

In my case, the problem was that I was passing the CELERY_RESULT_BACKEND argument to the celery constructor:

Celery('proj',
         broker = 'amqp://guest:guest@localhost:5672//',
         CELERY_RESULT_BACKEND='amqp://',
         include=['proj.tasks'])

The solution was to use the backend argument instead:

Celery('proj',
         broker = 'amqp://guest:guest@localhost:5672//',
         backend='amqp://',
         include=['proj.tasks'])

1πŸ‘

For users encountering this issue in 2023. If you are using Celery version 5.0 or greater, set CELERY_RESULT_BACKEND = "rpc://" in settings. If you are initializing the celery app, use the below code:

Celery('your_project_name',
     broker = 'amqp://guest:guest@localhost:5672//',
     backend='rpc://',
     include=['proj.tasks'])
πŸ‘€Inaam Ilahi

0πŸ‘

Some how the console has to have django environment set up in order to pick up the settings. For example, in PyCharm you can run django console, in which everything works as expected.

πŸ‘€airfang

0πŸ‘

See AMQP BACKEND SETTINGS for better understanding

Note The AMQP backend requires RabbitMQ 1.1.0 or higher to
automatically expire results. If you are running an older version of
RabbitMQ you should disable result expiration like this:
CELERY_TASK_RESULT_EXPIRES = None

Try adding the below line to your settings.py:

CELERY_TASK_RESULT_EXPIRES = 18000 # 5 hours

Leave a comment