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?
Redis can handle many connections, and by default, Redis has a maximum number of client connections set at 10,000 connections. You can set the maximum number of client connections you want the Redis server to accept by altering the maxclient from within the redis. conf file.
If you want to test redis connection once at startup, use the ping() command. The command ping() checks the connection and if invalid will raise an exception.
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.
So what I ended up doing was, removing uncommenting bind 127.0.0.1
to bind 0.0.0.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With