Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketT

windows中连接虚拟机中的redis报错如下

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out

原因分析如下:

1.IP或端口不正确

建议查看端口

2.虚拟机的防火墙没有关闭(一般这个原因大)

        建议进入linux操作系统将防火墙进行关闭。注意了!要先重启防火墙  service iptables restart

        然后再进行关闭   service iptables stop   

我是直接关闭防火墙的,然后多花了半个小时的时间来解决redis连接不上的问题,希望同样有这个问题的朋友先重启防火墙吧!

3.redis.conf 中bind 127.0.0.1 未用#注释掉

        建议进入redis.conf中找到bind 127.0.0.1,再bind 127.0.0.1前面加上#

4.将redis.conf 中protected-mode yes中的yes改为no

 

 

现在应该可以连接上了,希望对你有帮助!

你可能感兴趣的:(Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketT)