Talking with a redis remote server using redis-py (python shell on top of redis)

I installed redis on an independent database server (ec2 instance). And it was installed and configured properly. Now all I want to do is my web server, I connect to it and make changes to its store of key values.

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

Now I am installing https://github.com/andymccurdy/redis-py on my local server and web server.

To test the connection and see if it works 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. ConnectionError: Error 111 connecting 54.235.xxx.xxx:6379. Connection refused.

How to connect? What am I missing?

+4
source share
2 answers

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

+4
source

So what did I do in the end by removing uncommenting bind 127.0.0.1 to bind 0.0.0.0

+2
source

Source: https://habr.com/ru/post/1480667/


All Articles