Celery tries to connect to the wrong broker

2019-04-28 10:01发布

I have in my celery configuration

BROKER_URL = 'redis://127.0.0.1:6379'
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379'

Yet whenever I run the celeryd, I get this error

consumer: Cannot connect to amqp://guest@127.0.0.1:5672//: [Errno 111] Connection refused. Trying again in 2.00 seconds...

Why is it not connecting to the redis broker I set it up with, which is running btw?

2条回答
放我归山
2楼-- · 2019-04-28 10:43

If you followed First Steps with Celery tutorial, specifically:

app.config_from_object('django.conf:settings', namespace='CELERY')

then you need to prefix your settings with CELERY, so change your BROKER_URL to:

CELERY_BROKER_URL = 'redis://127.0.0.1:6379'
查看更多
够拽才男人
3楼-- · 2019-04-28 10:49

import your celery and add your broker like that :

celery = Celery('task', broker='redis://127.0.0.1:6379')
celery.config_from_object(celeryconfig)
查看更多
登录 后发表回答