redis getaddrinfo ENOTFOUND - node.js , redis connection

3.4k Views Asked by At

Hi im trying to connect to redis from node.js which is successful, now i hosted my node.js server app on amazon ec2 instance and redis on amazon elastic cache instance the connection to redis is succesful but once in a while i'm getting the below mentioned error.

var pub = redis.createClient(6379,'quizredis.qnsdtp.0001.apse1.cache.amazonaws.com'); 


events.js:72
    throw er; // Unhandled 'error' event
          ^       Error: Redis connection to quizredis.qnsdtp.0001.apse1.cache.amazonaws.com:6379 failed - getaddrinfo ENOTFOUND
at RedisClient.on_error (/home/ec2-user/roomChat-7/node_modules/redis/index.js:196:24)
at Socket.<anonymous> (/home/ec2-user/roomChat-7/node_modules/redis/index.js:106:14)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:813:16

Im using the redis-npm module;

1

There are 1 best solutions below

0
On

From what I understand, this is a DNS resolution error. Elasticache Redis is a VPC specific service. Its DNS records are available within the VPC only and often times, VPC is using custom DHCP options with custom DNS server - it may not have the records.

Check a few things -

  1. DNS server configured in your VPC. Check here.
  2. Check the output of nslookup command in your machine - if your using linux shell

nslookup quizredis.qnsdtp.0001.apse1.cache.amazonaws.com

Cheers!