我已經使用「npm install redis」安裝了redis。然後我運行該項目頁面node_redis生成的示例代碼。我得到這個node.JS - 無法使用redis工作
"error error: Redis connection to 127.0.0.1:6379 failed - EPERM, Operation not permitted"
我覺得我失去了一些東西,有人可以幫我指出來?下面是我的代碼使用
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();
});
是'127.0.0.6379 「這個問題中的拼寫錯誤還是與錯誤信息中顯示的一樣?應該是'127.0.0.1:6379'連接到localhost上的redis。 – samplebias 2011-04-27 03:05:57
只需確認:在運行代碼之前,您已在端口6379(默認端口)上的本地主機上啓動了Redis實例,對不對?如果是這樣,你是否有本地防火牆運行? – nicolaskruchten 2011-04-27 03:29:36
對不起,你說的「你已經啓動了Redis實例」是什麼意思?我只是運行代碼,我得到了錯誤。我沒有防火牆。 – 2011-04-27 04:00:08