Connection to Redis throwing connection timeout from NodeJS

1.4k views Asked by At

I have a redis server in an azure linux vm running one master, slave and sentinel in the same VM(A). When i try to connect to the redis sentinal from another VM(B) using redis-cli, i am able to connect and set and get values. But when i try to connect to the redis sentinel using ioredis module in nodeJS from VM(B), it is throwing a connection timeout error. I use the following code snippet to connect to the sentinel from node application

var Redis = require('ioredis');
    var redis =  new Redis({
  sentinels: [{ host: 'x.x.x.x', port: 26379}],
  name: 'mymaster'
});

The confusing part is, when i run the redis master, slave and sentinel in the same vm(A) and using '127.0.0.1' instead of 'x.x.x.x' the code works fine.

Any help is much appreciated.

0

There are 0 answers