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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content