Skip to content

ElastiCache Redis connectivity error `redis.exceptions.ResponseError: MOVED 4720`

0

When I try connect to a redis instance I have from a Lambda I get the following error

redis.exceptions.ResponseError: MOVED 4720 test-0001-001.appdev-testev.nannan.apse2.cache.amazonaws.com:6379

I'm quite certain it has to do with some security group setup I have.

How I have the security groups setup when the error occurs

RedisSG (This is attached to the Redis instance): InboundRules: 6379 to SG RedisClientSG OutboundRules: 6379 to SG RedisClientSG

RedisCLinetSG (This is attached to the Lambda): OutboundRules: 6379 to SG RedisSG

The above security group configuration causes the MOVED 4720 error, However when I change the 6379 references to ALL TCP I can connect to the Redis instance from the lambda without any issue.

What ports do I actually have to limit the security groups to? and; Why do I have to have more ports open?

Additionally, of note my Redis cluster is working in Cluster Mode.

asked 2 years ago179 views

2 Answers
2

Hello,

To connect to your Redis instance from your Lambda, you need to open at least ports 6379 and 6380 in the Outbound Rules, and your Lambda must be in the same VPC as your Redis. Here’s a way to connect to it in Python:

import redis

redisClient = redis.StrictRedis (
    host = <ENDPOINT>,
    port = 6379,
    decode_responses = True,
    ssl = True
)

Make sure to include the ssl = True parameter.

And as you are in in Cluster Mode, you also need to open the ports 16379-16380 according to that doc

Hope it helps 😊

EXPERT

answered 2 years ago

0

So turns out it is something to do with the ports but, also to do with the actual implementation of the redis connector and how it connects to different nodes.

Best explanation I found on fixing this problem was from here https://www.dragonflydb.io/error-solutions/redis-exceptions-responseerror-moved.

Will let you know which ports this actually connects on and uses.

answered 2 years 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.