gpt4 book ai didi

laravel - Redis 连接到 127.0.0.1 :6379 failed - connect ECONNREFUSED In laravel

转载 作者:IT王子 更新时间:2023-10-29 06:07:28 28 4
gpt4 key购买 nike

当我运行 node serve.js 时,出现以下错误

   throw er; // Unhandled 'error' event
^

Error: Redis connection to 127.0.0.1:6379 failed - connect ENFILE 127.0.0.1:6379 - Local (undefined:undefined)
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at connect (net.js:880:16)
at net.js:969:9
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)

Server.js 文件

  var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var redis = require('redis');

server.listen(8890);
io.on('connection', function (socket) {

console.log("client connected");
var redisClient = redis.createClient();
redisClient.subscribe('message');

redisClient.on("message", function(channel, data) {
console.log("mew message add in queue "+ data['message'] + " channel");
socket.emit(channel, data);
});

socket.on('disconnect', function() {
redisClient.quit();
});

});

我该如何解决以上错误。我已经安装了 node、npm、predis 和 socet.io

最佳答案

我遇到了同样的问题,但我通过安装 redis 并先前在终端中执行它解决了它。

如果您使用的是 mac,您可以使用以下命令通过 brew 轻松安装 redis:

brew install redis

安装后运行以下命令:

redis-serve

这件作品是给我的!

关于laravel - Redis 连接到 127.0.0.1 :6379 failed - connect ECONNREFUSED In laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44802385/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com