Javascript Redis 连接到 127.0.0.1:6379 失败 - 连接 ECONNREFUSED

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8754304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 07:22:27  来源:igfitidea点击:

Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED

javascriptnode.jssessionexpressredis

提问by Huy Tran

I working with node.js by expressjs
I try to store an account to session. So, i try to test to use session with code in expressjs

我通过 expressjs 使用 node.js
我尝试将帐户存储到会话。所以,我尝试测试在expressjs 中使用带有代码的会话

var RedisStore = require('connect-redis')(express);
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({ secret: "keyboard cat", store: new RedisStore }));

but I got error Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED.
Please help me resolve this problem

但我有错误Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
请帮我解决这个问题

回答by piggyback

After you install redis, type from terminal:

安装 redis 后,从终端输入:

redis-server

and you'll have redis running

你会运行redis

回答by V. Kovpak

I solve this problem in next way:

我用下一个方法解决这个问题:

sudo apt-get install redis-server

then run command to confirm that everything ok:

然后运行命令以确认一切正常:

sudo service redis-server status

And the output will be: redis-server is running- that means that the problem is solved.

输出将是:redis-server is running- 这意味着问题已解决。

回答by Partha Roy

Install redis on your system first -

首先在您的系统上安装 redis -

brew install redis

then start the redis server -

然后启动redis服务器——

redis-server

回答by Felix

I'm on windows, and had to install Redis from hereand then run redis-server.exe.

我在 Windows 上,必须从这里安装 Redis然后运行redis-server.exe.

From the top of this SO question.

这个 SO 问题的顶部开始。

回答by Shashwat Gupta

Simple solution:

简单的解决方案:

only hit below commend once and restart your server again

只在下面点赞一次,然后再次重启你的服务器

redis-server

回答by Bar?? Serkan AKIN

for Windows users, you can use chocolatey to install Redis

对于 Windows 用户,可以使用 Chocolatey 来安装 Redis

choco install redis-64

then run server from

然后从运行服务器

C:\ProgramData\chocolatey\lib\redis-64\redis-server.exe

回答by Sadegh

I also have the same problem, first I tried to restart redis-server by sudo service restartbut the problem still remained. Then I removed redis-serverby sudo apt-get purge redis-serverand install it again by sudo apt-get install redis-serverand then the redis was working again. It also worth to have a look at redis log which located in here /var/log/redis/redis-server.log

我也有同样的问题,首先我尝试重新启动 redis-serversudo service restart但问题仍然存在。然后我删除redis-serversudo apt-get purge redis-server和重新安装sudo apt-get install redis-server,然后Redis的再次合作。还值得一看位于此处的 redis 日志/var/log/redis/redis-server.log

回答by Paing Soe Thaw

I used ubuntu 12.04 I solved that problem by installing redis-server

我使用的是 ubuntu 12.04 我通过安装 redis-server 解决了这个问题

redis-server installation for ubuntu 12.04

ubuntu 12.04 的 redis-server 安装

some configuration will new root permission Also listed manuals for other OS

一些配置将新的 root 权限还列出了其他操作系统的手册

Thanks

谢谢

回答by decoder7283

Using Windows 10?Go here: https://docs.microsoft.com/en-us/windows/wsl/wsl2-install

使用 Windows 10?去这里:https: //docs.microsoft.com/en-us/windows/wsl/wsl2-install

Then run...

然后跑...

    $ wget https://github.com/antirez/redis/archive/5.0.5.tar.gz <- change this to whatever Redis version you want (https://github.com/antirez/redis/releases)
    $ tar xzf redis-5.0.5.tar.gz
    $ cd redis-5.0.5
    $ make

回答by Saiful Islam Sajib

You have to install redis server first;

你必须先安装redis服务器;

You can install redis server on mac by following step -

您可以按照以下步骤在 mac 上安装 redis 服务器 -

  $ curl -O http://download.redis.io/redis-stable.tar.gz
  $ tar xzvf redis-stable.tar.gz
  $ cd redis-stable
  $ make
  $ make test
  $ sudo make install
  $ redis-server

Good luck.

祝你好运。