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

Time:06-11

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.

CodePudding user response:

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,
     });
  • Related