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 127.0.0.1:6379

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 127.0.0.1:6379          0.0.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          0.0.0.0/0

But when I try to access from the python side:

import redis
r = redis.StrictRedis(host='ec2-xx-xxx-xx-xx.compute-1.amazonaws.com', port=6379, db=0)
r.set('foo', 'bar')
r.get('foo')

I get the following error:

ConnectionError: Error 111 connecting to ec2-xx-xxx-xx-xx.compute-1.amazonaws.com:6379. 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
• 14,960 points
243 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

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

tcp        0      0 127.0.0.1:6379 

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

# bind 127.0.0.1
bind 0.0.0.0

and then restart the service:

sudo service redis-server restart

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

answered Sep 26, 2018 by Priyaj
• 56,100 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

Trying to Determine Amazon EC2 instance creation date/time

You can't find as such attribute called ...READ MORE

answered May 29, 2018 in AWS by Flying geek
• 3,130 points
1,178 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.