Rajan Shah
Rajan Shah

Reputation: 165

AWS Elastic Cache Redis Cluster `MOVED XXXXX ip:6379` error

I am trying to connect to AWS Elastic Cache Redis Cluster and i keep getting this I am still getting the Error MOVED 12218 ip:6379

Following is the code

https://www.npmjs.com/package/redis - redis: ^4.0.1

import {createClient} from "redis";
const client = createClient({url: "redis://xyz.abc.clustercfg.use2.cache.amazonaws.com:6379"});
await client.connect();
console.log("client connected");
console.log(await client.ping());

OUTPUT:

client connected
PONG

But when I do await client.get(key) or await client.set(key, value) I get the MOVED error.

I even followed this https://github.com/redis/node-redis/issues/1782, but yet i am getting the same MOVED 12218 ip:6379 error.

Upvotes: 0

Views: 3307

Answers (2)

user3008410
user3008410

Reputation: 848

Just some info. I realized that I set up a Redis-Cluster Helm chart but I was connecting with Jedis from a Sentinel/Redis setup. Once I changed Jedis to connect with JedisCluster then this error went away. Now this is with a client so your setup might be different, but something to look at.

Upvotes: 0

dead_webdev
dead_webdev

Reputation: 256

I am hoping you are trying cluster mode enabled redis in aws.

"redis": "^4.1.0".

I am using this redis version If so then you can try this below code

    const redis = require('redis');

    const client = redis.createCluster({
      rootNodes: [
        {
          url: `redis://${ConfigurationEndpoint}:${port}`,
        },
      ],
      useReplicas: true,
     });

Upvotes: 1

Related Questions