UnknownHostException in Java application when calling getLocalHost

Solution Verified - Updated -

Issue

  • Error looking up local address caused by java.net.UnknownHostException at 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.getLocalHost throws UnknownHostException when host's defined host name cannot be resolved.

Environment

  • Java Virtual Machine
  • Call to getLocalHost to 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.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.