How to resolve java.net.Unknownhostexception error

Asked

Viewed 21,001 times

3

I’m trying to install the sqldeveloper and datamodeler in my Fedora 20 and I’m having trouble with following error:

java.net.UnknownHostException: localdomain: localdomain: Name or service not known
        at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
        at org.netbeans.CLIHandler$2.run(CLIHandler.java:667)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2044)
Caused by: java.net.UnknownHostException: localdomain: Name or service not known
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
        at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
        ... 3 more

I have Java 1.7.0_51 installed.

2 answers

5


This error occurs because the resolution of Java domain names is wanting the host name.

To resolve use:

HostnameVerifier hv = new HostnameVerifier() {
    public boolean verify(String hostname, SSLSession session) {  
        return true;
    }
};

So the name resolution will be ignored. Put this code before the connection call either RMI, Socket or Webservice.

5

I figured out how to fix the bug.

In case the application is starting a host using the machine name localdomain and trying to access it by name, as this name has no related IP it is giving this error.

I edited the file /etc/hosts and added the following line:

127.0.0.1    localdomain

This was enough for him to recognize the domain name and find it, causing both applications to stop giving error.

  • Thanks for the tip Gabriel, I had the same problem, man!

  • Value @Gabriel Gartz Helped me too.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.