There's some strange behavior i've found with node_redis on Aws EC2.
Let's say i have two EC2 instances.
First one is used for DB (Redis, MYSQL, etc.) and it has an IP like so ip-1-1-1-1.eu-west-1.compute.internal
Second one is for app based on NodeJS and it's IP is ip-2-2-2-2.eu-west-1.compute.internal
In the Security Groups i've added this:
6379 sg-351a0441 (default)
6379 sg-333b9044 (quicklaunch-0)
I use node_redis module to communicate with Redis. I need to connect from one instance to another.
So now i (probably) can connect to Redis (first server) from another one:
redis = require('redis');
client = redis.createClient(6379, 'ip-1-1-1-1.eu-west-1.compute.internal');
But this way causes error:
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
It tries to connect (!) to 127.0.0.1
istead of 1.1.1.1
.
I've said "OK. Let's try another way!"
redis = require('redis');
client = redis.createClient(6379, '1.1.1.1');
And.. BANG! The same error here:
Error: Redis connection to 1.1.1.1:6379 failed - connect ECONNREFUSED
So, maybe full redis url will help?
redis = require('redis');
client = redis.createClient(6379, 'redis://1.1.1.1');
No :(
Error: Redis connection to redis://10.248.118.246:6379 failed - getaddrinfo EADDRINFO
And same one when using internal url:
Error: Redis connection to redis://ip-1.1.1.1.eu-west-1.compute.internal:6379 failed - getaddrinfo EADDRINFO
So, what's wrong with it? Thanks in advance.