redis 测试连通性,可以ping通虚拟机,但redis服务器连不上,连接超时

代码没错,虚拟机上redis客户端也能运行,问题出在虚拟机的防火墙service ipatables 关了就行了


Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out
at redis.clients.jedis.Connection.connect(Connection.java:134)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:69)
at redis.clients.jedis.Connection.sendCommand(Connection.java:86)
at redis.clients.jedis.BinaryClient.ping(BinaryClient.java:82)
at redis.clients.jedis.Jedis.ping(Jedis.java:34)
at cn.onedirection.main.testRedis.main(testRedis.java:9)
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at redis.clients.jedis.Connection.connect(Connection.java:129)
... 5 more


你可能感兴趣的:(centOS,redis)