Cannot connect to redis while using Sentinels in django-redis

Currently I am trying to integrate redis into my django project which is docker based. I was able to integrate redis using the DefaultClient but it doesn't work for SentinelClient

My settings.py looks like this:

DJANGO_REDIS_CONNECTION_FACTORY = 'django_redis.pool.SentinelConnectionFactory'


SENTINELS = [
    ('redis://9b39d2b0eb5d', 26379),
]

# 9b39d2b0eb5d is the ip of redis sentinel container

CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': 'redis://redis-queue-1:6379',
        'OPTIONS': {
            'SENTINELS': SENTINELS,
            # django_redis.client.SentinelClient
            'CLIENT_CLASS': 'django_redis.client.SentinelClient',
            'CONNECTION_POOL_CLASS': 'redis.sentinel.SentinelConnectionPool',
        },
    }
}

It doesn't throw any exception, django just gets stuck on loading

Try using https://pypi.org/project/django-sentinel/

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis_master/sentinel-host1:2639,sentinel-host2:2639/0"
        "OPTIONS": {
            "PASSWORD": 's3cret_passw0rd!',
            "CLIENT_CLASS": "django_sentinel.SentinelClient",
        }
    }
}
Back to Top