This means that you have misconfigured your local resolver in some way.
getLocalHost()
is supposed to return the real local IP address, and getLoopbackAddress()
returns the loopback address, usually 127.0.0.1
(you say you are getting 127.0.1.1
; although that's not impossible, I still assume that's a typo?)
There are several situations that you can identify in the Java code for getLocalHost()
that will make it return the loopback address instead of the real address:
The local hostname is set to localhost
String local = impl.getLocalHostName();
// [...]
if (local.equals("localhost")) {
return impl.loopbackAddress();
}
Your code doesn't have permissions to get the local host adddress (it may be an applet or a Java WebStart application without permissions)
} catch (java.lang.SecurityException e) {
return impl.loopbackAddress();
}
In other situations, however, it should throw an UnknownHostException
.
If your problem is number 1, then you need to change the host name of your machine to something that resolved back to the IP number of your computer.
If your problem is number 2, then you need to make sure that your code gets the appropriate permission, for example by signing the applet or webstart application.