![](/img/trans.png)
[英]Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379 nodejs
[英]Redis keeps failing on Windows 10 with Node.JS : Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
考虑代码:
const mongoose = require("mongoose");
const redis = require("redis");
const util = require("util");
const redisUrl = "redis://127.0.0.1:6379";
const client = redis.createClient(redisUrl);
client.hget = util.promisify(client.hget);
const exec = mongoose.Query.prototype.exec;
mongoose.Query.prototype.cache = function(options = {}) {
this.useCache = true;
this.hashKey = JSON.stringify(options.key || "");
return this; // now it's chainable
};
... // More code ...
它产生:
events.js:173 抛出错误; // 未处理的“错误”事件 [0] ^ [0] [0] 错误:Redis 连接到 127.0.0.1:6379 失败 - 在 TCPConnectWrap.afterConnect [as oncomplete] 处连接 ECONNREFUSED 127.0.0.1:6379 [0](net. js:1054:14) [0] 在 RedisClient.on_error (C:\Development-X220\NODEJS\Redis\node_modules\redis\index.js:341:14) [0] 处发出“错误”事件 [0]在套接字。 (C:\Development-X220\NODEJS\Redis\node_modules\redis\index.js:222:14) [0] 在 Socket.emit (events.js:196:13) [0] 在 emitErrorNT (internal/streams/ destroy.js:91:8) [0] 在 emitErrorAndCloseNT (internal/streams/destroy.js:59:3) [0] 在 processTicksAndRejections (internal/process/task_queues.js:84:9) [0] [nodemon]应用程序崩溃 - 在开始之前等待文件更改...
并且:
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
知道如何解决吗?
我尝试从 Windows-10 的 CMD 运行 redis-server 并得到:
'redis-server' is not recognized as an internal or external command,
operable program or batch file.
还遵循了人们在这里提供的建议,但没有任何效果。
有什么建议么?
好的,我已经通过访问此链接修复了它:
https://github.com/rgl/redis/downloads
我正在为可能遇到相同问题的任何人发布阶段:
选择最上面的 EXE 文件并安装它。
在 Windows 10 之后,点击:FN + R
类型:services.msc
在列表中查找“Redis 服务器”,右键单击并选择“开始”。
就是这样,你已经启动并运行了。
您需要在使用之前安装软件,这就是最近 50 年来的情况。 考虑在 Windows 上安装 Redis 的指南。
'redis-server' 不是内部或外部命令、可运行程序或批处理文件。
这意味着您的 redis 服务器尚未运行,因此超时错误是意料之中的。
redis for windows is not official i think so it's best you run redis in docker or a linux host.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.