skip to Main Content

I recently created a Redis cluster on AWS elasticache and am having trouble connecting via redis-cli from my local machine. Every time I run the command:

redis-cli -h <redis_cluster_domain> -p 6379

the connection is never established and eventually exits due to timeout.

Eventually, I figured it’s blocking due to a setting on the security group, so I edited the inbound rules to allow all traffic from my IP address. Even after doing this I still cannot connect to the cluster. Any ideas why this might be?

2

Answers


  1. Chosen as BEST ANSWER

    I figured it out.

    Apparently, you cannot access elasticache clusters from outside AWS by default. In order to do this, you need to create a VPN through AWS and connect to that in order to reach your desired cluster.

    The steps to do this are outlined in this AWS tutorial here, but in more simple terms all I did was the following:

    1. Create and import a certificate of authority using the AWS Certificate Manager. You will use this certificate to authorize your VPN connection.

    2. Create a VPN Client Endpoint and attach the key and certificate generated in the previous step with it.

    3. Associate the VPC being used on your elasticache cluster with the VPN endpoint.

    4. Authorize all traffic on your VPN for all users.

    5. Add a route to the route table of your VPN endpoint to allow access from anywhere (0.0.0.0/0).

    6. Download VPN client configuration file locally and connect to the VPN using "openvpn" (you may need to brew install this) with your certificate and key created in the first step.

    This worked for me and I'm glad I figured it out. Now I can connect to my Redis cluster from my local machine using "redis-cli"!


  2. you can also do this via a jump server / bastion host and even local port forwarding.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search