Can't connect to redis using django-redis

6.6k views Asked by At

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

There are 2 answers

1
taman On BEST ANSWER

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
E.J. Brennan On

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.

http://aws.amazon.com/elasticache/faqs/