title: java Exception in thread "main" java.net.UnknownHostException: Test: Test: unknown error OS ubuntu
body: <p>This error is related to my previous question where I had an error with <code>InetAddress.getLocalHost()</code>. I found a <a href="https://stackoverflow.com/questions/1881546/inetaddress-getlocalhost-throws-unknownhostexception">suggestion</a> to add an entry in  <code>/etc/hosts</code>: </p>
  
  <pre><code>myip     localhost
  127.0.0.1   localhost
  127.0.1.1   test5
  </code></pre>
  
  <p>but my error is still not resolved.</p>
  
  <p>My code :</p>
  
  <pre><code>import java.net.*;
  
  public class InetAddressTest {
      public static void main(String args[]) throws UnknownHostException {
          InetAddress Address = InetAddress.getLocalHost();
  
      }
  }
  </code></pre>
  
  <p>Error :</p>
  
  <pre><code>Exception in thread "main" java.net.UnknownHostException: Sachin: Sachin: unknown error
      at java.net.InetAddress.getLocalHost(InetAddress.java:1484)
      at InetAddressTest.main(InetAddressTest.java:6)
  Caused by: java.net.UnknownHostException: Sachin: unknown error
      at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
      at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)
      at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)
      at java.net.InetAddress.getLocalHost(InetAddress.java:1479)
      ... 1 more
  </code></pre>