Redis connection timeout running on AWS EC2

1.4k views Asked by At

I have a redis server running on AWS EC2 (Amazon Linux 2, t3.small). The security group is configured for all hosts (development purpose) on port 6379 and also in redis conf, I have set bind 0.0.0.0 and protected mode off. Intilally i was able to connect to this redis instance from a python program but when i checked after some time it says

redis.exceptions.ConnectionError: Error 110 connecting to ec2-xx-xxx-xx-xxx.ap-southeast-2.compute.amazonaws.com:6379. Connection timed out

I tried creating a new instance but same problem occurs, event tried bind 0.0.0.0 ::1 but no success.

Python script, I am using to connect:

import redis

h="ec2-xx-xxx-xxx-xxx.ap-southeast-2.compute.amazonaws.com"
r = redis.Redis(host=h)
r.mset({"Croatia": "Zagreb", "Bahamas": "Nassau"})
r.get("Bahamas")
0

There are 0 answers