无法在127.0.0.1:6379连接到Redis:连接被拒绝 [英] Could not connect to Redis at 127.0.0.1:6379: Connection refused

查看:148
本文介绍了无法在127.0.0.1:6379连接到Redis:连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在digitalocean的Ubuntu 16.4中安装了Redis.

Installed a redis in ubuntu 16.4 in digitalocean.

我已通过编辑编辑将默认的redis服务器 127.0.0.1:6379 更改为我在Digitalocean 178.xxx.xxx.xxx:6379 中的IP> vim/etc/redis/redis.conf

I've changed the default redis server 127.0.0.1:6379 into my own ip in digitalocean 178.xxx.xxx.xxx:6379 by editing editing vim /etc/redis/redis.conf

之后,我尝试 redis-cli redis-cli shutdown 都对此做出了回应:无法通过127.0.0.1:6379连接到Redis:连接被拒绝

After that I tried redis-cli and redis-cli shutdown all responded this: Could not connect to Redis at 127.0.0.1:6379: Connection refused

但是如果 ps aux | grep redis

我得到:

redis    11734  0.0  0.1  41852  3892 ?        Ssl  15:45   0:11 /usr/local/bin/redis-server 178.xxx.xxx.xxx:6379
root     12735  0.0  0.0  12944   948 pts/0    S+   19:11   0:00 grep --color=auto redis

这正常吗?或者我该怎么办?

Is this normal?Or what should I do?

推荐答案

您应该做什么取决于您希望它如何工作...

What you should do depends on how you want it to work...

如果您希望能够通过任何网络接口连接到Redis,请在配置文件的开头添加#,以注释掉配置文件中的所有 bind 指令.在 bind 开头的行.

If you want to be able to connect to Redis via any network interface, comment out all the bind directives in your config file by putting a # at the start of the line beginning bind.

如果仅想通过指定178.xxx.xxx.xxx进行连接,则将以下内容放入配置文件中:

If you want to only be able to connect by specifying 178.xxx.xxx.xxx, then put the following in your config file:

bind 178.xxx.xxx.xxx


如果要使用127.0.0.1或178.xxx.xxx.xxx,请输入:


If you want to use 127.0.0.1 or 178.xxx.xxx.xxx, then put:

bind 178.xxx.xxx.xxx 127.0.0.1

我猜您想要此选项,但请参阅下面的安全说明.

I'm guessing you want this option, but see security note below.

但是,从安全的角度来看,通常不建议将Redis服务器公开给整个Internet-上面的所有选项都可以做到这一点.您可能想绑定到127.0.0.1,并设置从您的178.xxx.xxx.xxx公共地址到127.0.0.1的 ssh 隧道.

In general though, it is not advisable from a security point of view, to expose your Redis server to the whole Internet - and all the options above do exactly that. You probably want to bind to 127.0.0.1 and set up an ssh tunnel from your 178.xxx.xxx.xxx public address to 127.0.0.1.

无论您放置在哪里,都可以重新启动Redis以使更改生效.

Whatever you put in there, restart Redis to make changes take effect.

这篇关于无法在127.0.0.1:6379连接到Redis:连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆