Search code examples
djangonginxredisgunicorndjango-channels

Setting requirepass on redis throws 'NOAUTH Authentication required'


I tried using the options setting to provide the password as such:

CHANNEL_LAYERS = {
    'default': {
        'BACKEND': 'channels_redis.core.RedisChannelLayer',
        'OPTIONS': {
            "PASSWORD": 'pass',               },                                                                                                                                   'CONFIG': {
            'hosts': [('localhost', 6379)],                                                                                                  }
    }
}

Despite this, it is erroring:

Exception Value: NOAUTH Authentication required.

I found the following SO:

Redis raise error: NOAUTH Authentication required but there is no password setting

But the answers were not helpful in this situation.


Solution

  • Note: If you have any special symbols in your password it will throw base 10 error. You're going to either have to convert the password to be url friendly or use a password without special characters.

    CHANNEL_LAYERS = {
        "default": {
            "BACKEND": "asgi_redis.RedisChannelLayer",
            "CONFIG": {
                "hosts": [("redis://:[email protected]:6379/0")],
            },
        },
    }
    

    Credits to PanosTrak from Discord and this github issue