错误报告:

-DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command ‘CONFIG SET protected-mode no’ from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to ‘no’, and then restarting the server. 3) If you started the server manually just for testing, restart it with the ‘–protected-mode no’ option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
遗失对主机的连接。

解决办法:

根据你提供的信息,Redis 正在以保护模式(protected mode)运行,这意味着它只接受来自本地回环接口(127.0.0.1)的连接。为了允许外部连接,你需要按照Redis给出的建议进行配置更改。

解决方案 1:临时禁用保护模式

可以通过redis-cli从同一台主机上发送命令来临时禁用保护模式。这不会影响其他配置文件设置,并且仅在当前会话中有效。

redis-cli
CONFIG SET protected-mode no

然后你可以使用CONFIG REWRITE命令将此更改永久保存到配置文件中:

 CONFIG REWRITE

注意:确保你的Redis服务器没有公开暴露在互联网上,否则这可能会带来安全风险。

解决方案 2:编辑配置文件禁用保护模式

编辑Redis配置文件(通常是/etc/redis/redis.conf),找到并修改以下行:

protected-mode no

同时,考虑设置一个绑定地址或密码保护:

# 绑定到所有网络接口或特定IP地址
bind 0.0.0.0
# 设置密码保护(推荐)
requirepass your_strong_password

保存更改后重启Redis服务:
在这里插入图片描述

sudo systemctl restart redis

解决方案 3:启动时禁用保护模式

如果你只是想临时测试,可以在启动Redis时添加–protected-mode no选项:

redis-server --protected-mode no

解决方案 4:设置绑定地址或密码保护

这是最推荐的做法,因为它既保持了安全性又允许远程连接。如上所述,在配置文件中设置bind和requirepass指令。

安全注意事项

  • 不要简单地关闭保护模式,尤其是在生产环境中。确保你了解这样做可能带来的安全风险。
  • 使用防火墙规则限制哪些IP可以访问Redis端口,即使你启用了密码保护。
  • 设置强密码,并且定期更换。
  • 监控和日志记录可以帮助你检测任何异常活动。

测试连接

完成上述更改后,请再次尝试从Windows客户端连接。如果仍然无法连接,请检查云服务器的安全组设置以及操作系统级别的防火墙配置,确保6379端口是开放的,并且允许来自你的Windows机器的入站连接。
在这里插入图片描述

如果你已经尝试了这些步骤但问题依旧存在,可以向提供更多的错误信息或日志输出,以便进一步诊断。

AI帮助: https://tongyi.aliyun.com/qianwen/

如何部署软件请看此处:

https://blog.csdn.net/qq_45086538/article/details/144150919?spm=1001.2014.3001.5502

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐