Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't connect to redis using django-redis

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.

like image 590
taman Avatar asked Dec 08 '14 18:12

taman


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.

like image 194
taman Avatar answered Oct 08 '22 06:10

taman


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/

like image 24
E.J. Brennan Avatar answered Oct 08 '22 07:10

E.J. Brennan