以下两种情况同时满足时,会触发Redis的protected-mode:

  • 未使用 bind 指令明确配置一组IP地址。
  • 未配置密码。

当服务器同时存在这两种情况时,客户端(非服务器本机)可以正常连接。但是进行数据操作时报错:

(error) DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients.

解决方案

  1. 在服务器上使用客户端连接Redis,运行 “CONFIG SET protected-mode no”命令禁用保护模式。
  2. 编辑Redis配置文件,将protected-mode 设置为no,然后重启服务器。
  3. 使用 “--protected-mode no” 选项重启服务器。
  4. 编辑Redis配置文件,设置绑定地址或验证密码(只需要执行其中一个操作,即可接受外部连接)。

小伍
139 声望4 粉丝