UnknownHostException in Java application when calling getLocalHost
Issue
Error looking up local addresscaused byjava.net.UnknownHostExceptionat startup.-
Java fails when looking up a JMX server with error:
Error executing command: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ConfigurationException [Root exception is java.rmi.UnknownHostException: Unknown host: example; nested exception is: java.net.UnknownHostException: example] -
Java's
java.net.InetAddress.getLocalHostthrows UnknownHostException when host's defined host name cannot be resolved.
Environment
- Java Virtual Machine
- Call to
getLocalHostto retrieve private or local platform's host name
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
