I've got a django project using django-redis 3.8.0 to connect to an aws instance of redis. However, I receive ConnectionError: Error 111 connecting to None:6379. Connection refused. when trying to connect. If I ssh into my ec2 and use redis-py from the shell, I am able to read and write from the cache just fine, so I don't believe it's a security policy issue.
2 Answers
Ok, figured it out. What I needed to do was prefix my location with redis://. This is specific to the django-redis library and how it parses the location url. That explains why when I manually set up a StrictRedis connection using the python redis library I was able to connect.
1 Comment
If you are running elastic-cache redis, you can't access it from outside AWS - that is why you are getting the error.
From AWS FAQ:
Please note that IP-range based access control is currently not enabled for Cache Clusters. All clients to a Cache Cluster must be within the EC2 network, and authorized via security groups as described above.
REDIS_HOST)?CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "myawsredislocation:6379", 'KEY_PREFIX': 'projectname', "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", } } }