我正在使用Redis DB和NodeJS。偶尔我会遇到异常,我的服务器(NodeJS)崩溃只会重新启动。
Error: Redis connection to localhost:6380 failed - getaddrinfo ENOTFOUND
有人可以解释为什么会这样吗?以下配置是否与此有关?
# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able ot configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# maxclients 10000
答案 0 :(得分:4)
这只是意味着你的redis服务器没有运行;至少不在那个地址/端口上。
使用
启动服务器$ redis-server path/to/redis.conf
此外,默认的redis端口为 6379 。如果您在脚本中使用6380,请确保redis正在侦听该端口。
如果脚本中的某些内容导致redis服务器崩溃,您可以尝试侦听错误以获得更明智的输出
var redis = require("redis"),
client = redis.createClient(6380, "localhost");
client.on("error", function (err) {
console.log("Redis error encountered", err);
});
client.on("end", function() {
console.log("Redis connection closed");
});