java.net.UnknownHostException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

When kafka creates new consumers, it simply concatenate the name of your VM to generate the consumer id. So, your VM resolves localhost as the name of your VM, not whatever you had set. To solve, add kafka(or the name of VM) plus address to /etc/hosts

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • FULL PRODUCT VERSION : $ java -version java version "1.7.0_05" Java(TM) SE Runtime Environment (build 1.7.0_05-b05) Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode) ADDITIONAL OS VERSION INFORMATION : OSX 10.7.4 $ uname -a Darwin d9y8kt71.corp.skytide.com 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr 9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64 EXTRA RELEVANT SYSTEM CONFIGURATION : $ hostname d9y8kt71.corp.skytide.com $ hostname -f d9y8kt71.corp.skytide.com A DESCRIPTION OF THE PROBLEM : Run the following test driver program on Oracle java7u5 on OSX. It throws an exception even though it should not. Note that the very same program runs fine on java6u33 on the very same OSX host and config. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Run the following test driver program on Oracle java7u5 on OSX. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The program should print something like d9y8kt71.corp.skytide.com ACTUAL - [hoschek /sky/cdnapp/build/classes] java -cp . HostNameTest Exception in thread "main" java.net.UnknownHostException: d9y8kt71.corp.skytide.com: d9y8kt71.corp.skytide.com: nodename nor servname provided, or not known at java.net.InetAddress.getLocalHost(InetAddress.java:1438) at HostNameTest.main(HostNameTest.java:8) Caused by: java.net.UnknownHostException: d9y8kt71.corp.skytide.com: nodename nor servname provided, or not known at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258) at java.net.InetAddress.getLocalHost(InetAddress.java:1434) ... 1 more ERROR MESSAGES/STACK TRACES THAT OCCUR : See full stack trace above. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.net.InetAddress; import java.net.UnknownHostException; public class HostNameTest { public static void main(String[] args) throws UnknownHostException { String version = System.getProperty("java.version"); System.out.println(version + " getHostName(): " + InetAddress.getLocalHost().getHostName()); System.out.println(version + " www.google.com.getHostName(): " + InetAddress.getByName("www.google.com").getHostName()); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : We are not aware of any workaround.
    via by Webbug Group,
  • Unable to open h2.jar on mac
    via Stack Overflow by user2167441
    ,
  • Not able to open sonar server on the web browser
    via Stack Overflow by Tom
    ,
  • DSpace Tech Support - Unable to set localhost
    via by Unknown author,
  • No title
    via by Unknown author,
    • java.net.UnknownHostException: d9y8kt71.corp.skytide.com: d9y8kt71.corp.skytide.com: nodename nor servname provided, or not known at java.net.InetAddress.getLocalHost(InetAddress.java:1438) at HostNameTest.main(HostNameTest.java:8) Caused by: java.net.UnknownHostException: d9y8kt71.corp.skytide.com: nodename nor servname provided, or not known at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866) at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258) at java.net.InetAddress.getLocalHost(InetAddress.java:1434) ... 1 more

    Users with the same issue

    Unknown visitor1 times, last one,
    raj76
    2 times, last one,
    nasimk
    2 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    60 more bugmates