首页 > 解决方案 > 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.

标签: djangonginxredisgunicorndjango-channels

解决方案


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://:mypassword@127.0.0.1:6379/0")],
        },
    },
}

Credits to PanosTrak from Discord and this github issue


推荐阅读