Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

The redis is running in the ec2 instance via daemon

ps aux | grep redis-server

redis     1182  0.0  0.8  38856  8740 ?        Ssl  21:40   0:00 /usr/bin/redis-server

netstat -nlpt | grep 6379

(Not all processes could be identified, non-owned process info

 will not be shown, you would have to be root to see it all.)

tcp        0      0*               LISTEN      -               

tcp6       0      0 :::6379                 :::*                    LISTEN      1388/redis-server *

Temporarily I have set network inbound to all traffic so it is likely not a problem of network security.

Type         Protocol Port Range   Source      Description

All traffic  All           All       

But when I try to access from the python side:

import redis

r = redis.StrictRedis(host='', port=6379, db=0)

r.set('foo', 'bar')


I get the following error:

ConnectionError: Error 111 connecting to Connection refused.

What may cause such issue despite network inbound is open to all traffic and redis running fine in the ec2 instance?

1 Answer

0 votes
by (44.4k points)

First, your redis is listening to connections only locally because of the IP address which is provided. So, you will have to make your bind-address to

tcp        0      0 

Now, you will have to change your redis.conf file. The path to the file is /etc/redis/redis.conf. After opening the file, do the below part

bind - change this to the one below


After you have changed it, save the file and restart the service using the below command

sudo service redis-server restart

Now, try running the same and it should work.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
asked Jul 1, 2019 in AWS by Amyra (12.9k points)
0 votes
1 answer
asked Jul 12, 2019 in AWS by yuvraj (19.1k points)
0 votes
1 answer

Browse Categories