idea 连接redis 出现 Caused by: java.net.SocketTimeoutException: connect timed out

Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out
    at redis.clients.jedis.Connection.connect(Connection.java:207)
    at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93)
    at redis.clients.jedis.Connection.sendCommand(Connection.java:126)
    at redis.clients.jedis.Connection.sendCommand(Connection.java:121)
    at redis.clients.jedis.BinaryClient.multi(BinaryClient.java:486)
    at redis.clients.jedis.BinaryJedis.multi(BinaryJedis.java:1737)
    at cn.edu.aynu.redis.TestTx.main(TestTx.java:15)
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:184)
    ... 6 more

Process finished with exit code 1

我的错误的原因是,ip地址写错了。
启动时报错

 

第二种当进行主从复制时,也出现了这个错误,然后我把防火墙关了 

service iptables stop

就能正常访问了。

posted @ 2019-04-11 19:14  纳兰容若♫  阅读(10125)  评论(0编辑  收藏  举报