0

I had a problem connecting to aws elasticache, I found some solutions but couldn't solve the problem. Hope anyone can help.

const redis = createClient({
  socket: {
    host: process.env.REDIS_HOST,
    port: Number(process.env.REDIS_PORT),
    tls: true,
    connectTimeout: 30000,
  },
});



error logs

Redis Client Error Error: connect ETIMEDOUT
2
  • Is this code running in the same VPC as the ElastiCache server? Or is it running on your local computer or something? What are the security group rules of the ElastiCache server? Commented Nov 9, 2024 at 12:52
  • this code is running local, security group open port 6379(any where ipv4) , all traffic(any where ipv4) (inbound) Commented Nov 9, 2024 at 14:48

3 Answers 3

0

The ETIMEDOUT error typically occurs when the connection to the AWS ElastiCache (Redis) cluster cannot be established within the specified timeout. Check the connectivity, security groups, make sure the host name is correct. Simple debug step: try to connect with cli command from the same security group, networking, and see wether you can connect or no.

Sign up to request clarification or add additional context in comments.

Comments

0

"this code is running local"

ElastiCache servers don't get public IP addresses. If you do a DNS lookup of that hostname you are trying to connect to, you will see it is a private IP address that will only work within your VPC.

2 Comments

How can I choose to use a redis cache service?
Please clarify your question. I don't understand what your comment is asking.
0

The ElastiCache service is designed to be accessed exclusively from within AWS.

If you want to access it from your local machine, the easiest and the cheapest way is to you use Jumpbox/Bastion instance and AWS SSM Start-Session with port forwarding (https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-sessions-start.html#sessions-remote-port-forwarding).

First install the Session Manager plugin for AWS CLI (https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html)

Login via CLI to AWS and run:

aws ssm start-session \
    --target jumpbox-instance-id \
    --document-name AWS-StartPortForwardingSessionToRemoteHost \
    --parameters '{"host":["redis-host.abcdef.0001.euw2.cache.amazonaws.com"],"portNumber":["6379"], "localPortNumber":["6379"]}'

Then you can access your redis on localhost:6379. Make sure to test first with tls disabled.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.