The World’s Largest Online Community for Developers

'; amazon web services - How to connect to ElastiCache cluster using node.js - LavOzs.Com

We know that ElastiCache is not recommended to be accessed outside Amazon instances, so we're trying below stuff inside Amazon EC2 instances only.

We've got a ElastiCache Redis Cluster with 9 nodes. When we try to connect to it using normal redis implementation, it throws some Moved errors

Have tried the retry strategy method as per @Miller. Have also tried RedisCluster with unstable and stable (poor man) implementations.

None of these implementations are working. Any suggestions please?

Sharing the code for future readers:

var RedisClustr = require('redis-clustr');
var RedisClient = require('redis');
var config = require("./config.json");

var redis = new RedisClustr({
    servers: [
            host: config.redisClusterHost,
            port: config.redisClusterPort
    createClient: function (port, host) {
        // this is the default behaviour
        return RedisClient.createClient(port, host);

//connect to redis
redis.on("connect", function () {

//check the functioning
redis.set("framework", "AngularJS", function (err, reply) {
  console.log("redis.set " , reply);

redis.get("framework", function (err, reply) {
  console.log("redis.get ", reply);
How do I debug Node.js applications?
Writing files in Node.js
How do I pass command line arguments to a Node.js program?
Read environment variables in Node.js
How to decide when to use Node.js?
How to exit in Node.js
What is the purpose of Node.js module.exports and how do you use it?
Can you connect to Amazon ElastiСache Redis outside of Amazon?
Connect to ElastiCache cluster from AWS Lambda function