Could not connect to Redis at 127.0.0.1:6379: Connection refused

大城市里の小女人 提交于 2019-12-24 21:14:49

问题


Installed a redis in ubuntu 16.4 in digitalocean.

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

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

But if ps aux|grep redis

I get:

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?


回答1:


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


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.


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

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.


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.

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



来源:https://stackoverflow.com/questions/52084594/could-not-connect-to-redis-at-127-0-0-16379-connection-refused

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!