Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery beat + redis with password throws No Auth exception

I am using celery and redis as two services in my docker setup. Configuration is as below:

  redis:
    image: redis:latest
    hostname: redis
    ports:
      - "0.0.0.0:6379:6379"
    command:
      --requirepass PASSWORD

  celeryworker:
    <<: *django
    depends_on:
      - redis
      - postgres
    command: "celery -E -A rhombus.taskapp worker --beat --scheduler redbeat.schedulers:RedBeatScheduler --loglevel INFO --uid taskmaster --concurrency=5"

When I try to build my containers and schedule some jobs once the workers are ready I get an exception

[2018-03-20 04:40:52,082: WARNING/Beat] redis.exceptions.ResponseError: NOAUTH Authentication required.

I have been unable to figure out what else would be required as configuration to get this setup working. Some insights and guidance into the issue is appreciable.

Below is the complete stack trace.

Complete stack trace

like image 220
Rajesh Yogeshwar Avatar asked Mar 20 '18 04:03

Rajesh Yogeshwar


2 Answers

If you have authentication for redis, then URI should be in this format.

broker_url = 'redis://user:password@redishost:6379/0'

The URI you mentioned is not a valid redis uri. If you update URI, it should work.

Without authentication, uri should be

broker_url = 'redis://redishost:6379/0'
like image 87
Pandikunta Anand Reddy Avatar answered Nov 06 '22 15:11

Pandikunta Anand Reddy


Alternatively, according to the celery docs, if you don't have an explicit user set up, you can set the broker url like this:

broker_url='redis://:password@hostname:port/db_number'
like image 26
afterburner Avatar answered Nov 06 '22 13:11

afterburner