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.

  • This might be a won't-fix. If the HostName (`scutil --get HostName`) contains a whitespace the, logback will throw an error ``` 20:04:52,128 |-ERROR in ch.qos.logback.core.util.ContextUtil@36b37b66 - Failed to get local hostname java.net.UnknownHostException: MacBook Pro: MacBook Pro: nodename nor servname provided, or not known at java.net.UnknownHostException: MacBook Pro: MacBook Pro: nodename nor servname provided, or not known at at java.net.InetAddress.getLocalHost(InetAddress.java:1438) at at ch.qos.logback.core.util.ContextUtil.getLocalHostName(ContextUtil.java:32) at at ch.qos.logback.core.util.ContextUtil.addHostNameAsProperty(ContextUtil.java:41) at at ch.qos.logback.classic.joran.action.ConfigurationAction.begin(ConfigurationAction.java:56) at at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276) at at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) at at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130) at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:157) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56) at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75) at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148) at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84) at at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:54) at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128) at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107) at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281) at at com.srhub.nscrg.core.SpellsParserTest.<init>(SpellsParserTest.java:46) at at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:187) at at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236) at at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233) at at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.net.UnknownHostException: MacBook Pro: nodename nor servname provided, or not known at at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866) at at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258) at at java.net.InetAddress.getLocalHost(InetAddress.java:1434) at ... 43 common frames omitted ``` I don't even know if this is allowed [1] but OSX allows setting the HostName it directly via `scutil --set HostName "MacBook Pro"` [1] http://tools.ietf.org/html/rfc952
    via by Oliver Schrenk,
  • This might be a won't-fix. If the HostName (`scutil --get HostName`) contains a whitespace the, logback will throw an error ``` 20:04:52,128 |-ERROR in ch.qos.logback.core.util.ContextUtil@36b37b66 - Failed to get local hostname java.net.UnknownHostException: MacBook Pro: MacBook Pro: nodename nor servname provided, or not known at java.net.UnknownHostException: MacBook Pro: MacBook Pro: nodename nor servname provided, or not known at at java.net.InetAddress.getLocalHost(InetAddress.java:1438) at at ch.qos.logback.core.util.ContextUtil.getLocalHostName(ContextUtil.java:32) at at ch.qos.logback.core.util.ContextUtil.addHostNameAsProperty(ContextUtil.java:41) at at ch.qos.logback.classic.joran.action.ConfigurationAction.begin(ConfigurationAction.java:56) at at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276) at at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) at at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130) at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:157) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56) at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75) at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148) at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84) at at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:54) at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128) at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107) at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281) at at com.srhub.nscrg.core.SpellsParserTest.<init>(SpellsParserTest.java:46) at at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:187) at at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236) at at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233) at at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.net.UnknownHostException: MacBook Pro: nodename nor servname provided, or not known at at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866) at at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258) at at java.net.InetAddress.getLocalHost(InetAddress.java:1434) at ... 43 common frames omitted ``` I don't even know if this is allowed [1] but OSX allows setting the HostName it directly via `scutil --set HostName "MacBook Pro"` [1] http://tools.ietf.org/html/rfc952
    via by Oliver Schrenk,
  • GitHub comment 7#34648006
    via GitHub by dankerrigan
    ,
    • java.net.UnknownHostException: MacBook Pro: MacBook Pro: nodename nor servname provided, or not known at java.net.InetAddress.getLocalHost(InetAddress.java:1438) at ch.qos.logback.core.util.ContextUtil.getLocalHostName(ContextUtil.java:32) at ch.qos.logback.core.util.ContextUtil.addHostNameAsProperty(ContextUtil.java:41) at ch.qos.logback.classic.joran.action.ConfigurationAction.begin(ConfigurationAction.java:56) at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276) at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130) at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:157) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:143) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:106) at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56) at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75) at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148) at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84) at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:54) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281) at com.srhub.nscrg.core.SpellsParserTest.<init>(SpellsParserTest.java:46) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:187) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:236) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:233) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.net.UnknownHostException: MacBook Pro: 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) ... 43 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