Redis客户端操作指令 报错(error) DENIED Redis is running in protected mode because protected mode is enabled

本文解决了一个常见的Redis客户端连接错误问题,即由于服务器和客户端IP地址不匹配导致的连接失败。通过调整客户端连接命令和服务器配置文件,实现了正确的连接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 问题:Redis数据库客户端操作报错

(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. In this mode connections are only accepted from the loopback interface.(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. In this mode connections are only accepted from the loopback interface.在这里插入图片描述

  • 原因:

对于这种类型的报错一般都是客户端连接的服务器和启动的redis服务器不是同一个
例如:你的服务器连接的是本机host的127.0.0.1
而你的客户端启动的却是192.168.23.129
所以操作的时候导致报错。

  • 解决过程:
  1. 首先我看到报错:
    Redis is running in protected mode because protected mode is enabled
    以为是我的protected-mode 是开着,看了一下是关的。
    在这里插入图片描述
  2. 接着我把客户端运行命令由 redis-cli -h 192.168.23.129 -p 6381
    改为了 redis-cli -p 6381
    注意:如果没有-h 就是默认的是本机ip也就是127.0.0.1
    结果发现能够执行命令不报错了。
    在这里插入图片描述
  3. 原来我的服务器启动的是127.0.0.1这一个,
    但是我的客户端连接的确实192.168.23.129这个
    我打开我的redis-6381.conf配置文件,发现我把#bind 192.168.23.129给注释了
    在这里插入图片描述
  4. 去掉注释,重启服务器就能够操作192.168.23.129这个服务器了

总结:

  1. 如果客户端启动 redis-cli -p 6381 没有-h就是默认本机ip 127.0.0.1
  2. 如何把bind 192.168.23.129注释掉 也是默认启动本地服务器
  3. 如果想连接其他服务器只需要把 bind 后面的ip改为你想要的重启服务器即可
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值