In AWS i am using ElastiCache Redis server and using node as backEnd and "promise-redis" package
this is how i am tried to do to connect to my redis server endpoint
client = redis.createClient({
host: '**my redis primary endpoint**',
port: 6379
});
this worked for a while but after adding some lines of code not related to redis
it gave me this error
error: connect ECONNREFUSED 127.0.0.1:6379
it seems trying to connect to the local server and ignoring the host endpoint i gave to him
and when i changed the port to any number like 6300
it gave the same error with the default port number too
error: connect ECONNREFUSED 127.0.0.1:6379
i am so confused please help !!!!
2
Answers
these "geniuses" changed such a significant thing in their library as the connection and didn’t even give a good warning about it. I’m already silent about the fact that it is a crime to make such changes when your library in a million projects is already coded. Now you need to connect like this:
I advise you to switch to the ioredis library, there is an old api, only the client is created through new Redis ({old config})
Because in this old library ("redis"), for some reason they now require an asynchronous connect () for some functionality, without really explaining why and when it is needed, and when it is not needed. Half of the code works for me, and half does not.
So, use better this:
Make sure the host key does not have the protocol part "http://" in it
If you include the protocol in your host key, the redis client defaults to using localhost – 127.0.0.1