user1629366
user1629366

Reputation: 2011

talking to a remote redis server using redis-py (python wrapper over redis)

I have installed redis on an independent database server(ec2 instance). And it has been installed and configured properly. Now all that I want to do is from my webserver, I connect to it, and make changes to its key value store.

I have a python/django application running on heroku, and I am using PostgreSQL for everything else, I am using redis just to store some temporary variable in the KV sets.

Now, I install https://github.com/andymccurdy/redis-py on my localserver, and webserver.

To test the connection and check if things are working well, I try the following in my environment :

>>> pool = redis.ConnectionPool(host='MY_DBSERVER_IP_ADDRESS', port=6379, db=0)
>>> r = redis.Redis(connection_pool=pool)
>>> r.set('foo', 'bar')

this gives me an error - ConnectionError: Error 111 connecting 54.235.xxx.xxx:6379. Connection refused.

How do I connect? What am I missing?

Upvotes: 5

Views: 7687

Answers (2)

user1629366
user1629366

Reputation: 2011

So what I ended up doing was, removing uncommenting bind 127.0.0.1 to bind 0.0.0.0

Upvotes: 3

William K
William K

Reputation: 76

By default the config is set to only bind to 127.0.0.1 You just need to find your config (/etc/redis/redis.conf on Ubuntu) and comment out the bind 127.0.0.1 line.

Upvotes: 6

Related Questions