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?
Confirm the security group on the ElastiCache cluster Select the cluster name from the Redis clusters menu, and then select the Network and security tab. 2. Verify that at least one of the associated security groups allows inbound connections from the client resource to the cluster on the cluster's port.
Firewall restriction is another common reason that can trigger the “could not connect to Redis connection refused”. By default Redis server listen to the TCP port 6379. If another application is using the port or if the firewall restrictions blocks the port, it can trigger the connection refused error.
Sign in to the AWS Management Console and open the ElastiCache console at https://console.aws.amazon.com/elasticache/ . From the navigation pane, choose Redis clusters. The clusters screen will appear with a list of Redis (cluster mode disabled) and Redis (cluster mode enabled) clusters.
To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command. In the above example, we connect to Redis server running on the local machine and execute a command PING, that checks whether the server is running or not.
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.
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:
Wait until your ElastiCache Instance is done modifying then ssh into your EC2 Instance. Finally, try Matt's ping
pong
method.
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With