6
votes

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:

enter image description here

On runcloud (that I used for this instance) I also opened the port and successfully deployed the firewall rules:

enter image description here

Same timeout. What am I missing?

2
Just a suggestion, outbound rules allow all traffic?Grynets
Did you set it to open to public access on your Elasticache end? (You are only showing your ec2 inbound security group)number5

2 Answers

10
votes

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.

2
votes

Matt's answer lead me in the right direction. However, a small adjustment made my connection work. I looked over the security groups and I noticed that the security group that I had open connections to (i.e.Custom TCP 6379) wasn't bound to my ElastiCache Redis instance.

To modify your security groups in your ElastiCache Instance:

  • Click on your instance (make sure its highlighted)
  • Click on the Actions Dropdown Menu
  • Modify
  • VPC Security Groups (click on pencil icon)
  • Select Security Groups & Save
  • Finally, click on Modify

Wait until your ElastiCache Instance is done modifying then ssh into your EC2 Instance. Finally, try Matt's ping pong method.

Hope it helps!