Trying to connect to redis running on ec2 instance locally but getting error despite all traffic inbound

+1 vote

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 ?

Sep 26, 2018 in AWS by bug_seeker
• 15,480 points

1 answer to this question.

0 votes

Your redis is not listening for connections from outside, instead it listening for local connections only.

tcp        0      0 

Following works for Ubuntu. Edit /etc/redis/redis.conf and bind it to

# bind

and then restart the service:

sudo service redis-server restart

WARNING: Do not allow in your security group. Anyone is allowed. Instead allow only specific IPs or CIDRs.

answered Sep 26, 2018 by Priyaj
• 57,660 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer