无法连接到linux的redis服务

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

学习springboot整合redis的时候连不上linux虚拟机的redis数据库
尝试了很多办法也无用

vim redis.conf

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

注释掉 #bin 127.0.0.1

都没有用的情况下
就是linux 的防火墙的问题

1)检查防火墙状态
[root@localhost bin]# /etc/init.d/iptables status

Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all – 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp – 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all – 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:8080
6 ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:3306
7 ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:6379
8 REJECT all – 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all – 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num target prot opt source destination

2)放开6379端口(redis默认端口,如修改过,则放开相应端口)
2.1)vi /etc/sysconfig/iptables

    添加一行内容为**:-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT**
  
2.2)重启防火墙 /etc/init.d/iptables restart

完美解决!!!!!!!!!!!!!!!困扰了我一上午的bug!

你可能感兴趣的:(无法连接到linux的redis服务)