java.net.SocketException: Can't assign requested address
Caused by: java.net.SocketException: Can't assign requested address at java.net.PlainDatagramSocketImpl.join(Native Method) at java.net.AbstractPlainDatagramSocketImpl.join(AbstractPlainDatagramSocketImpl.java:178) at java.net.MulticastSocket.joinGroup(MulticastSocket.java:323) at com.alibaba.dubbo.registry.multicast.MulticastRegistry.<init>(MulticastRegistry.java:90) ... 22 more
This was caused by an IPv6 address being returned from java.net.NetworkInterface.getDefault()
. I'm on a Macbook and was using wireless -- p2p0 (used for AirDrop) was returned as the default network interface but my p2p0 only has an IPv6 ether
entry [found by running ipconfig
].
Two solutions, both of which worked for me (I prefer the first because it works whether you are using a wired or wireless connection)
Start the JVM with
-Djava.net.preferIPv4Stack=true
. This causedjava.net.NetworkInterface.getDefault()
to return my vboxnet0 network interface -- not sure what you'll get if you're not running a host-only VM.Turn off wireless and use a wired connection