Title: How to connect AWS elasticache redis from Node.js application?
Tags: javascript;node.js;amazon-web-services;amazon-elasticache
Question: How to connect AWS elasticache redis from Node.js application ?


Here is another answer: You can try connecting using ioredis.
var Redis = require('ioredis');
var config = require("./config.json");
const redis = new Redis({
host: config.host,
port: config.port,
password: config.password, // If you have any.
tls: {}, // Add this empty tls field.
redis.on('connect', () =&gt; {
console.log('Redis client is initiating a connection to the server.');
redis.on('ready', () =&gt; {
console.log('Redis client successfully initiated connection to the server.');
redis.on('reconnecting', () =&gt; {
console.log('Redis client is trying to reconnect to the server...');
redis.on('error', (err) =&gt; console.log('Redis Client Error', err));
//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);

Here is another answer: You can use the package ioredis
and stablish a connection like this
const Redis = require('ioredis')
const redis = new Redis({
port: 6379,
host: 'your-redis-host',
connectTimeout: 10000 // optional
});

Here is another answer: You're connecting to Redis. The fact that it's a managed AWS service is not really that important in this respect.
So, use a Node.js package that implements a Redis client interface, for example:
node-redis

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:05/20/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><node.js><amazon-web-services><amazon-elasticache>', 'Title': 'How to connect AWS elasticache redis from Node.js application?', 'ViewCount': 4974, 'id': 61922063, 'user_AboutMe': '', 'user_AccountId': 18244867.0, 'user_DisplayName': 'Dev7867', 'user_Reputation': 61.0, 'user_Views': 12.0, 'user_id': 13281204.0}}