Jenkins is Experiencing UnknownHostException

Article ID:218156717
2 minute readKnowledge base

Issue

  • The Jenkins instance hangs when installing plugins

  • An UnknownHostException occurs on startup:

2016-02-07 02:45:07.730+0000 [id=73]    WARNING javax.jmdns.impl.HostInfo#newHostInfo: Could not intialize the host network interface on nullbecause of an error: <my-hostname>: <my-hostname>: unknown errorjava.net.UnknownHostException: <my-hostname>: <my-hostname>: unknown error
    at java.net.InetAddress.getLocalHost(InetAddress.java:1484)
    at javax.jmdns.impl.HostInfo.newHostInfo(HostInfo.java:75)
    at javax.jmdns.impl.JmDNSImpl.<init>(JmDNSImpl.java:407)
    at javax.jmdns.JmDNS.create(JmDNS.java:60)
    at hudson.DNSMultiCast$1.call(DNSMultiCast.java:32)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.UnknownHostException: <my-hostname>: 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)
    ... 9 more

Resolution

1. Disable DNS Discovery

This could be due to the Auto-discovering of Jenkins with DNS Multicast. If you are not using this functionality you can disable it by adding the following properties on startup and restart your instance:

-Dhudson.DNSMultiCast.disabled=true -Dhudson.udp=-1

If Jenkins is running on Apache Tomcat, you can add the following property to catalina.properties:

hudson.DNSMultiCast.disabled=true hudson.udp=-1

2. Troubleshoot your Hosts/DNS configuration

This could be a misconfiguration of your hostnames or your DNS (if using a DNS).

Use ping of telnet to check that the host can be resolved:

$ ping my-hostname PING my-hostname (127.0.0.1): 56 data bytes ... $ telnet my-hostname jenkins-port Trying 127.0.0.1... Connected to my-hostname. Escape character is '^]'.

If you are not using a DNS, check that the <hostname> is defined in /etc/hosts:

[...]

127.0.0.1   localhost my-hostname

[...]

If you are using a DNS, try to telnet on DNS port to check that the port is open (default port is 53):

$ telnet my-hostname dns-port
Trying 127.0.0.1...
Connected to my-hostname.
Escape character is '^]'.

Command like nslookup, dig and host can help you to troubleshoot DNS issues:

# Query a hostname for the default server
nslookup my-hostname

# Query a hostname for a different server
nslookup my-hostname my-dns-server

# List IP address(es) associated with a hostname/domain:
host -l my-hostname

# Query a hostname for the default server
dig my-hostname

# Query a hostname for the different server
dig @my-server my-hostname