admin管理员组

文章数量:1571108

redis 通过ip连接失败

报错1

报错:Could not connect to Redis at 192.168.137.154:6379: Connection refused

原因: redis认为直接在互联网上暴露redis端口是危险的,所以redis遵信bind指令,强制redis只监听IPV4回退接口地址(即:只能够接收同一台计算机的连接)

例如:(Linux: /etc/redis/redis.conf)
redis.conf文件中配置了,注解掉即可,或配置多个访问IP

bind 127.0.0.1
或
bind 127.0.0.1 192.168.0.1

报错2

报错:RedisConnectionException: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, 

原因:Linux上的redis处于一种安全保护状态,(bind指令注释将redis暴露),所以外部就无法轻易连接。

Linux: /etc/redis/redis.conf)

总结三种解决方式

1、 bind指令注释去掉,指定IP
bind 127.0.0.1 192.168.0.
2、关闭保护模式

protected-mode no  
3、redis设置密码

requirepass 123456

本文标签: SpringBootipRedis