Using redis gives an error

I installed redis on the links. https://github.com/mranney/node_redis

and try

var redis = require("redis"), client = redis.createClient(); client.on("error", function (err) { console.log("Error " + err); }); client.set("string key", "string val", redis.print); client.hset("hash key", "hashtest 1", "some value", redis.print); client.hset(["hash key", "hashtest 2", "some other value"], redis.print); client.hkeys("hash key", function (err, replies) { console.log(replies.length + " replies:"); replies.forEach(function (reply, i) { console.log(" " + i + ": " + reply); }); client.quit(); }); 

and node test.js

gives me this error why?

 Error Error: Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED, Connection refused 

why does this error occur? What should I do?

+4
source share
2 answers

You need to make sure the server is running before you can access it in Node.Js

+6
source

It is worth noting that you must first install the redis server by running

sudo apt-get install redis-server

and then if it is not running, you can run it by running

Redis server

0
source

All Articles