0

Am using django-redis in Django to add Azure redis cache, but I am getting issues with the connection, I added the keys password and the hostname and the port but no luck , I get this error :

django_redis.exceptions.ConnectionInterrupted: Redis ConnectionError: Error while reading from myhostname.net:6380 : (104, 'Connection reset by peer')

I tried reading existing answers but no luck.

This is what I have in my Django settings.py :

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": os.getenv('REDIS_URL'),
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            'SSL': True,
            "PASSWORD": os.getenv('REDIS_PASSWORD'),
        }
    }
}

Where REDIS_URL is like this :

REDIS_URL=rediss://myhostname.net:6380

and as well as REDIS_PASSWORD the password provided.

What could I be missing, am testing this on Digitalocean, I have an SSL activated.

Lutaaya Huzaifah Idris
  • 3,596
  • 8
  • 38
  • 77

1 Answers1

1
  • Here I was not getting the connection error by using the Location tag in the following format
"LOCATION":'rediss://:<Your password>@<name of the redis in azure>.redis.cache.windows.net:6380/0'

The complete code:

CACHES = {
    'default':{
                'BACKEND':'django_redis.cache.RedisCache',
                "LOCATION":'rediss://:<Your password>@<name of the redis in azure>.redis.cache.windows.net:6380/0',
                'OPTION':{
                            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
                            'PASSWORD':'<Your password>',
                            'SSL': True
                        }
            }
}

After starting the Django app, output:

enter image description here

Mohit Ganorkar
  • 1,917
  • 2
  • 6
  • 11