admin管理员组文章数量:1414614
Consider the code :
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 ...
It produces :
events.js:173 throw er; // Unhandled 'error' event [0] ^ [0] [0] Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379 [0] at TCPConnectWrap.afterConnect [as onplete] (net.js:1054:14) [0] Emitted 'error' event at: [0] at RedisClient.on_error (C:\Development-X220\NODEJS\Redis\node_modules\redis\index.js:341:14) [0] at Socket. (C:\Development-X220\NODEJS\Redis\node_modules\redis\index.js:222:14) [0] at Socket.emit (events.js:196:13) [0] at emitErrorNT (internal/streams/destroy.js:91:8) [0] at emitErrorAndCloseNT (internal/streams/destroy.js:59:3) [0] at processTicksAndRejections (internal/process/task_queues.js:84:9) [0] [nodemon] app crashed - waiting for file changes before starting...
And also :
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
Any idea how to fix it ?
I've tried to run redis-server from CMD of Windows-10 and got :
'redis-server' is not recognized as an internal or external mand,
operable program or batch file.
Also followed on the suggestions people offered here but nothing worked.
Any suggestions ?
Consider the code :
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 ...
It produces :
events.js:173 throw er; // Unhandled 'error' event [0] ^ [0] [0] Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379 [0] at TCPConnectWrap.afterConnect [as onplete] (net.js:1054:14) [0] Emitted 'error' event at: [0] at RedisClient.on_error (C:\Development-X220\NODEJS\Redis\node_modules\redis\index.js:341:14) [0] at Socket. (C:\Development-X220\NODEJS\Redis\node_modules\redis\index.js:222:14) [0] at Socket.emit (events.js:196:13) [0] at emitErrorNT (internal/streams/destroy.js:91:8) [0] at emitErrorAndCloseNT (internal/streams/destroy.js:59:3) [0] at processTicksAndRejections (internal/process/task_queues.js:84:9) [0] [nodemon] app crashed - waiting for file changes before starting...
And also :
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
Any idea how to fix it ?
I've tried to run redis-server from CMD of Windows-10 and got :
'redis-server' is not recognized as an internal or external mand,
operable program or batch file.
Also followed on the suggestions people offered here but nothing worked.
Any suggestions ?
Share Improve this question asked Apr 8, 2020 at 6:57 JANJAN 21.9k66 gold badges190 silver badges336 bronze badges3 Answers
Reset to default 4OK , I've fixed it by going to this link :
https://github./rgl/redis/downloads
I'm posting the stages for anyone who might encounter the same problem :
Picking the top EXE file and installing it.
After that in Windows 10 , hit : FN + R
Type : services.msc
Look for the "Redis Server" in the list , right click and choose "Start".
That's it , you're up and running.
You need to install software before using it, this is how it has been for recent 50 years. Consider this guide on installing Redis on Windows.
'redis-server' is not recognized as an internal or external mand, operable program or batch file.
that means your redis server is not running yet so the timeout error is kind of expected.
redis for windows is not official i think so it's best you run redis in docker or a linux host.
本文标签:
版权声明:本文标题:javascript - Redis keeps failing on Windows 10 with Node.JS : Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNRE 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745191244a2646919.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论