Caused by: java.net.ConnectException: Connection refused: connect的错误及解决方式

时间:2024-03-15 12:16:50

Caused by: java.net.ConnectException: Connection refused: connect
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:149)
... 32 more
出现这个错误之后按照网上的解决方案试了好多都没有效果,有的说把bind 127.0.0.1 
Caused by: java.net.ConnectException: Connection refused: connect的错误及解决方式
但是我的注释掉之后还是没有用
,最后问了同事,解决方式如下:

Caused by: java.net.ConnectException: Connection refused: connect的错误及解决方式

将bind修改为 bind 0.0.0.0   使得所有计算机都可以连上,或者配置指定的ip地址,如上图,两者任选其一,亲测有效
(最后说明我的版本是centos6~)