Java and /etc/resolv.conf DNS server failover

On Linux java will delegate hostname resolution to the underlying C system library which does the actual resolving.

The name servers will be queried in the order listed as specified in /etc/resolv.conf after the other sources of information specified in /etc/nsswitch.conf have been queried (think /etc/hosts but possibly NIS or LDAP).

You can specify a timeout value in /etc/resolv.conf , according to the man page the default is 5 seconds.

If your first server gives a valid error code I.e. servfail the second name server will not be queried


As a program (any process, JVM included) has its very first DNS request it reads and caches forever the entire contents of /etc/resolv.conf by default. It never refreshes that info later, even when it encounters a total DNS failure. The program would need to have some specific system calls programmed to behave in more user-friendly manner. This SO question explains the details.

I suspect that you edited /etc/resolv.conf while the JVM was running. Restart it.