By using AWS re:Post, you agree to the Terms of Use

Elastic BeanStalk can't connect to ElastiCache Redis

0

I'm having issues connecting from Elastic BeanStalk to ElastiCache Redis. When I SSH into the EBS instance and try to use redis-cli to connect, it times out. This is how I set up my environment:

I have an existing VPC with two subnets.

I created a Security Group specifically for this that has an Inbound rule for IPv4, Custom TCP, port 6379, source 0.0.0.0/0

I created an ElastiCache Redis cluster with the following relevant parameters:

Cluster mode: disabled

  • Location: AWS Cloud, Multi-AZ enabled
  • Cluster settings: number of replicas - 2
  • Subnet group settings: existing subnet group with two associated subnets
  • Availability Zone placements: no preference
  • Security: encryption at rest enabled, default key
  • Security: encryption in transit enabled, no access control
  • Selected security groups: the one I described above

As for the EBS environment, it has this configuration:

  • Platform: managed, Node.js 16 on Amazon Linux 2 5.5.3
  • Instance settings: Public IP address UNCHECKED, both Instance subnets checked
  • Everything else left default

After getting all of that set up, I would SSH into the EBS instance and follow the directions here to install redis-cli and try to connect: https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/GettingStarted.ConnectToCacheNode.html

I've tried using the Primary endpoint, the Reader endpoint, and all of the individual node endpoints, but I get a timeout error for all of them.

Is there some configuration that I'm missing?

1 Answers
0

Hi there,

I understand you are trying to connect to your Redis cluster from your Elastic Beanstalk instance but you are getting the timeout error. Timeout error is usually caused by how you have configured your security groups, Network Access Control Lists and Route Tables. If your EBS instance and Redis cluster are in the same VPC. On your inbound rules for Redis Cluster allow access from the security group used by your EBS instance instead of 0.0.0.0/0. When your Redis cluster is in the same VPC as the instance, the security group that you will use to control access to your cluster is the one associated with the VPC [1]. If your EBS instance and Redis cluster are in different VPCs you will have to setup a VPC connection first following the steps in this documentation and ensure that:

  • SG and NACL on the ElastiCache allow inbound traffic from on port 6379 from the security group used by your EBS instance and,
  • SG and NACL on the Beanstalk instance allow outbound connections to the ElastiCache on the port 6379

References:

  1. Using Elastic Beanstalk with Amazon ElastiCache
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions