欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

解决办法:java.net.SocketException: Address family not supported by protocol family:

程序员文章站 2022-06-16 08:05:24
...

 

java.net.SocketException: Address family not supported by protocol family: connect
 at sun.nio.ch.Net.connect(Native Method)
 at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:532)
 at org.apache.zookeeper.ClientCnxnSocketNIO.registerAndConnect(ClientCnxnSocketNIO.java:277)
 at org.apache.zookeeper.ClientCnxnSocketNIO.connect(ClientCnxnSocketNIO.java:287)
 at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:1024)
 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1060)

 

方法1:设置hosts文件
使localhost指向IPV4地址127.0.0.1
127.0.0.1       localhost

 

方法2:设置JVM参数
-Djava.net.preferIPv4Stack=true

 

方法3:设置系统属性
System.setProperty("java.net.preferIPv4Stack", "true");

相关标签: dubbo zookeeper