Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: 解决办法

问题:今天测试测流程,发现项目报下面这个错误

Redis exception; nested exception is io.lettuce.core.RedisException: io.lettuce.core.RedisConnectionException: 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的保护模式开启了,并且没有绑定ip地址,没有密码认证

解决:
 

找到redis的配置文件 redis.conf并编辑

vim redis.conf

1)修改 protected-mode  yes 改为:protected-mode no

2)如果本地可以,部署到服务器上不行,记得把 bind 127.0.0.1 注释。

3)设置密码访问模式,在redis.conf中加入一行密码设置 

  require 你的密码(这里有个空格)

注:记得项目重启,项目重启,项目重启!!!!(就是这个坑了我好长时间)

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 127.0.0.1:6379 是一个Redis连接失败的异常信息。根据引用,这个异常可能是由于无法连接到Redis服务器导致的。根据引用,在Java连接Redis时,可能需要对Redis进行一些配置,例如修改redis.conf文件中的protected-mode配置项为no,注释掉bind 127.0.0.1这一行,并设置连接密码requirepass。重新启动Redis服务器后,尝试重新连接即可。另外,根据引用,默认情况下,Redis只支持本地访问,所以需要将bind 127.0.0.1这一行注释掉,才能允许其他机器连接到Redis服务器。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Unable to connect to Redisnested exception is io.lettuce.core.RedisConnectionException:](https://blog.csdn.net/qq_45745319/article/details/123754785)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [连接本机redis报错Unable to connect to Redis](https://blog.csdn.net/ooyyaa6561/article/details/127663704)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值