timeout connecting to redis hosted on aws ElastiCache
See original GitHub issueHi,
I have a redis server hosted by aws using aws ElastiCache. When I try to connect to it using a lambda and on my local machine, it gives ‘timeout connecting to server’ error. However, my colleague could connect to this redis using another client in PHP. I wonder what I did wrong.
try:
redisClient = redis.Redis(host='***.use1.cache.amazonaws.com', port=6379, db=0, socket_timeout=10)
print(redisClient)
try:
print(redisClient.ping())
print(redisClient.set('foo','bar'))
# r.get('foo')
except Exception as e:
print('get set error: ', e)
except Exception as e:
print('redis err: ', e)
// redisClient Redis<ConnectionPool<Connection<host=***.use1.cache.amazonaws.com,port=6379,db=0>>>
// get set error: Timeout connecting to server for ping or set
Without setting the socket_timeout parameter, it will time out based on redis-py operation timeout: Error 60 connecting to ***.use1.cache.amazonaws.com:6379. Operation timed out.
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (3 by maintainers)
Top Results From Across the Web
Troubleshooting - Amazon ElastiCache for Redis
The timeout is the time in seconds allowed for idle connections to persist. If the client doesn't submit any request in the period,...
Read more >AWS Elasticache Timeout from EC2 - Stack Overflow
I had VPC setup, on the same network, could connect to redis on my local through OpenVPN and it was still timing out...
Read more >timeout connecting to redis hosted on aws ElastiCache
I have a redis server hosted by aws using aws ElastiCache. When I try to connect to it using a lambda and on...
Read more >AWS Elasticache Redis connection timed out - Laracasts
'redis' => [ 'client' => 'predis', 'redis' => [ 'host' => env('REDIS_HOST', '127.0.0.1'), // This is primary endpoint from elasticache settings 'password' => ......
Read more >Ecs unable to connect to redis elasticache, timeout error!
Ecs unable to connect to redis elasticache, timeout error! · Both of them are in same vpc. · Redis has same subnet group...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I ran into this issue as well, but from a Lambda. For me, there were a few problems that had to be ironed out
redis.RedisClietn(... ssl=True). The redis-py page mentions thatssl_cert_reqsneeds to be set toNonefor use with ElastiCache, but that didn’t seem to be true in my case. I did however need to passssl=True.It makes sense that
ssl=Trueneeded to be set but the connection was just timing out so I went round and round trying to figure out what the problem with the permissions/VPC/SG setup was.