[Solved]-Consumer Connection error with django and celery+rabbitmq?

12👍

Your problem is in the BROKER_URL.

With an additional VHOST, the right config would be:

BROKER_URL='amqp://celeryuser@localhost:5672//'
BROKER_VHOST='/celeryhost'
👤Amit

4👍

For me, the following URL ending worked:
…@localhost:5672/celeryvhost

4👍

I had similar issue with RabbitMQ and problem was that my user doesn’t have permission to create messages in RabbitMQ.

Try run the following script on your RabbitMQ server with guest user and if it creates a job try it with your user:

from celery import Celery

app = Celery('tasks', broker='amqp://radek:**@localhost:5672//')

@app.task
def add(x, y):
    return x + y

If you got the same error just set up the permission for your user:

rabbitmqctl set_permissions -p / radek ".*" ".*" ".*"

1👍

Your rabbitmq server must not be up and/or configured properly. Verify that it is and try again – or, better yet, if you are just trying to test something out and you are queue agnostic, take out rabbitmq and start using redis. It is much easier to configure.

I just cut-and-pasted this code from one of my project, and it works just fine:

import djcelery
from datetime import timedelta

djcelery.setup_loader()


BROKER_BACKEND = "redis"
BROKER_HOST = "localhost"
BROKER_PORT = 6379
BROKER_VHOST = "0"

CELERYD_LOG_LEVEL  = 'DEBUG'
CELERY_RESULT_BACKEND = "redis"
CELERY_TASK_RESULT_EXPIRES = 150000
REDIS_HOST = "localhost"
REDIS_PORT = 6379
REDIS_DB = "0"
CELERYD_CONCURRENCY = 1
CELERYD_MAX_TASKS_PER_CHILD = 4

CELERY_IMPORTS = (
    "apps.app1.tasks",
    "apps.app2.tasks",
)

1👍

What does your BROKER_URL look like in settings.py?

By default RabbitMQ has a guest user, so if you can connect with

BROKER_URL = "amqp://guest:guest@localhost:5672//"

then the problem is your setup for RabbitMQs user, password, or virtualhost.

👤Jess

Leave a comment