skip to Main Content

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.

2

Answers


  1. 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,
         });
    
    Login or Signup to reply.
  2. 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.

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