9

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

Community
  • 1
  • 1
Rajesh Yogeshwar
  • 2,111
  • 2
  • 18
  • 37

2 Answers2

14

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'
Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
  • 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! – adhg Jan 17 '19 at 02:28
  • 1
    @adhg Yes, you need to define it in docker. – Chillar Anand Jan 17 '19 at 05:04
  • 1
    What is value for user – Parikshit Chalke Aug 27 '19 at 08:00
  • user, password will be the auth credentials for redis. – Chillar Anand Aug 27 '19 at 09:04
  • But how does someone get the username for redis? Based on this https://stackoverflow.com/questions/46569432/does-redis-use-a-username-for-authentication redis does not require a user name for authentication. – David Essien Aug 29 '19 at 11:40
  • It is optional. If it requires authentication, get appropriate credentials from where it is setup. – Chillar Anand Aug 30 '19 at 12:57
  • 12
    It seems that the default user is 'default', as described in the [redis.conf](https://github.com/antirez/redis/blob/unstable/redis.conf#L673) file. – Avikd Sep 06 '19 at 19:09
6

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'
afterburner
  • 2,552
  • 13
  • 21