Celery beat + redis with password throws No Auth exception
Asked Answered
M

2

12

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

Metencephalon answered 20/3, 2018 at 4:49 Comment(4)
Can you post your celery config?Overeager
What exactly are you interested in when you say config? settings variables?Metencephalon
Yes. broker url and backend url.Overeager
My celery broker url and backend url is redis://6UZ316WI93FV5TAJFQIRMGUOEYCU5KNS@redis:6379/0Metencephalon
O
20

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'
Overeager answered 22/3, 2018 at 3:54 Comment(7)
wonder if I can plug your expertise on this one: If you define the user:password in the settings.py for redis. Should you also define the user:password in Docker (or you can leave it empty, as in no container's environment)? Thank you!Krasnoyarsk
@Krasnoyarsk Yes, you need to define it in docker.Overeager
What is value for userPontefract
user, password will be the auth credentials for redis.Overeager
But how does someone get the username for redis? Based on this #46569932 redis does not require a user name for authentication.Flashboard
It is optional. If it requires authentication, get appropriate credentials from where it is setup.Overeager
It seems that the default user is 'default', as described in the redis.conf file.Strait
O
10

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'
Oceangoing answered 30/6, 2022 at 8:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.