Reputation: 93
I already read all the other threads on stackoverflow about the ECONNREFUSED error but still nothing worked. Currently I am working on Ubuntu 12.04.1 LTS
For tests I have this really simple code:
var redis = require("redis"),
client = redis.createClient(6379,"127.0.0.1");
redis.debug_mode = true;
client.on("connect", function () {
client.set("foo_rand000000000000", "some fantastic value");
});
But whenever I am starting it, all I get is the ECONNREFUSED error:
root@oncn05:~/ba# node test.js
hiredis parser not installed.
Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
at RedisClient.on_error (/root/ba/node_modules/redis/index.js:196:24)
at Socket.<anonymous> (/root/ba/node_modules/redis/index.js:106:14)
at Socket.emit (events.js:67:17)
at Array.0 (net.js:319:25)
at EventEmitter._tickCallback (node.js:192:41)
root@oncn05:~/ba#
The thing is: It is no problem to connect to redis with redis-cli
.
root@oncn05:~/ba# redis-cli
redis 127.0.0.1:6379>
Also the logs do not show anything suspicious.
Why is it even saying that the hiredis parser is not installed? I installed it with npm install hiredis
. But even if i didn't. Where is it even used?
I appreciate every help.
Upvotes: 6
Views: 6727
Reputation: 93
First of all: Thank you to everyone who read and/or answered my question.
Normally it makes no difference if you pass createClient these parameters, because 127.0.0.1:6379 is the default setting.
I recognized that I had an old node.js version (0.6.xx), so I decided to completly delete it and than reinstall it.
So, first I deleted node with the command sudo apt-get remove nodejs
. Afterwards I installed the new version like it is stated here: installing via package manager
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Now everything works as expected. I don't know why i didn't think of this earlier.
Upvotes: 2