I created cache.t2.small
Redis under ElastiCache. It's available.
I have the endpoint: portal-test.abcdef.ab.0001.abcd1.cache.amazonaws.com
.
I ssh
'ed to the instance (tried via ubuntu@ip-172-xx-xx-xx
and runcloud@ip-172-xx-xx-xx
). I'm trying to connect via redis-cli
by typing:
redis-cli -h portal-test.abcdef.ab.0001.abcd1.cache.amazonaws.com -p 6379 ping
I expect PONG
but instead I get
Could not connect to Redis at portal-test.abcdef.ab.0001.abcd1.cache.amazonaws.com:6379: Connection timed out
I went into my EC2 instance and defined the inbound traffic for port 6379
:
On runcloud (that I used for this instance) I also opened the port and successfully deployed the firewall rules:
Same timeout. What am I missing?
I've found the solution.
Culprit:
Redis I created was not in the same VPC / Availability Zone / Subnet as the EC2 instance where my Laravel app lives. First one had IP 10.x.x.x > while the EC2 instance was 172.x.x.x. I assume this mismatch was preventing both ends to talk to each other. 🧠🧠ðŸ§
Solution:
When you create Redis, simply assign it to the same VPC as your existing EC2 instance where your Laravel baby lives. Also reuse the same security group where you open port 6379 (assuming you picked this port as a default one when creating your Redis).
Now SSH into you EC2 and from within type:
redis-cli -h endpoint-from-your-aws-redis-dashboard -p 6379 ping
If you get:
PONG
you're the winner.