Search code examples
pythondjangorabbitmqcelerydjango-celery

Celery cannot connect to RabbitMQ server


I am trying to run celery and it is unable to connect to the RabbitMQ server even though I have correctly set the user, vhost and assigned the appropriate tags

celery -A proj worker -l info

The above command returns the error

[2021-09-28 18:05:37,649: ERROR/MainProcess] consumer: Cannot connect to amqp://test:**@12:5672//: timed out.
Trying again in 2.00 seconds... (1/100)

I have initialized the celery app as follows

app = Celery('proj',
             broker=f'amqp://test:test@12#4@localhost/test_vhost')

I believe this is not working because the password test@12#4 has the special characters @ and # in it.

How do I get this to work without changing the password.



Solution

  • This issue can be solved using escape sequences.

    The issue is not with the @ character but with the #

    So if your password is test@12#4, you can simply use the escape sequence for the # character which is %23

    The password can be written as test@12%234