question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot connect to redis 6.0 as broker if username supplied in url

See original GitHub issue

Similar to https://github.com/celery/celery/issues/6422. Fixed for Celery backend only in 5.1.2

There is a problem with broker connections to redis6 where authentication to a username is required.

for code such as

from celery import Celery
url = "rediss://someuser:somepassword@somehost.databases.appdomain.cloud:31349"
app = Celery('tasks', broker=url,
    result_backend=url,
    broker_use_ssl = {
        'ssl_cert_reqs': 'required',
        'ssl_ca_certs': '/home/showcase/rediscelery/cert.crt'
    },
    redis_backend_use_ssl = {
        'ssl_cert_reqs': 'required',
        'ssl_ca_certs': '/home/showcase/rediscelery/cert.crt'
    }
)

you get the error

[2021-10-18 15:49:19,184: ERROR/MainProcess] consumer: Cannot connect to rediss://someuser:**@somehost.databases.appdomain.cloud:31349//: WRONGPASS invalid username-password pair.
Trying again in 2.00 seconds... (1/100)

This is caused by kombu not extracting the username from the URL.

The relevant file is kombu/transport/redis.py. The following fix is suggested, add 'username': conninfo.userid, to connparams assignment as

   def _connparams(self, asynchronous=False):
        conninfo = self.connection.client
        connparams = {
            'host': conninfo.hostname or '127.0.0.1',
            'port': conninfo.port or self.connection.default_port,
            'virtual_host': conninfo.virtual_host,
            'username': conninfo.userid,
            'password': conninfo.password,
            'max_connections': self.max_connections,
            'socket_timeout': self.socket_timeout,
            'socket_connect_timeout': self.socket_connect_timeout,
            'socket_keepalive': self.socket_keepalive,
            'socket_keepalive_options': self.socket_keepalive_options,
            'health_check_interval': self.health_check_interval,
            'retry_on_timeout': self.retry_on_timeout,
        }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
auvipycommented, Oct 29, 2021

consider donating through https://opencollective.com/celery plz

1reaction
auvipycommented, Oct 28, 2021

Updating to kombu = “5.2.0rc1” so try celery 5.2.0rc1. i am going to relese kombu 5.2 tomorrow hopefully

Read more comments on GitHub >

github_iconTop Results From Across the Web

Celery cannot connect to redis >6.0 using ACL user:password ...
I am not sure if I understand. the URL is passed as broker_url or as result_backend ? Run into the same issue when...
Read more >
WRONGPASS invalid username-password pair or user is ...
I am sure the user name and password correct because I could login redis using the redis-cli command. where is the problem and...
Read more >
Docker - Celery cannot connect to redis - Stack Overflow
You are trying to use redis on a localhost host, but you need to change your configuration to point to host redis ....
Read more >
How To Connect to a Redis Database - DigitalOcean
Whether you've installed Redis locally or you're working with a remote instance, you need to connect to it to perform most operations.
Read more >
Configuration and defaults — Celery 5.2.7 documentation
Username used to connect to the database. Note that this is only supported in Redis>=6.0 and with py-redis>=3.4.0 installed. If you use an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found