且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法在127.0.0.1:6379连接到Redis:连接被拒绝

更新时间:2022-11-16 23:00:00

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

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.