apache/hadoop · error · UnknownHostException
Error resolving host
Error message
Error resolving host
What it means
SecurityUtil installs a Guava-cache-backed InetAddress resolver for Kerberos host lookups. When cache.get(host) fails with a cause other than UnknownHostException (timeouts, ExecutionException wrapping a resolver failure), the cause is unwrapped and rethrown as UnknownHostException prefixed with 'Error resolving host', carrying the underlying message.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java:630
return resolve(key);
}
});
}
}
protected abstract InetAddress resolve(String host) throws UnknownHostException;
@Override
public InetAddress getByName(String host) throws UnknownHostException {
if (cache != null) {
try {
return cache.get(host);
} catch (Exception e) {
Throwable cause = e.getCause();
if (cause instanceof UnknownHostException) {
throw (UnknownHostException) cause;
}
String message = (cause != null ? cause.getMessage() : "Unknown error");
throw new UnknownHostException("Error resolving host " + host + ": " + message);
}
} else {
return resolve(host);
}
}
@VisibleForTesting
public LoadingCache<String, InetAddress> getCache() {
return cache;
}
}
/**
* Uses standard java host resolution
*/
static class StandardHostResolver extends CacheableHostResolver {
StandardHostResolver(long expiryIntervalSecs) {
super(expiryIntervalSecs);View on GitHub (pinned to 2add963021)
Solutions
- Resolve the named host manually on the affected node: getent hosts <host> and nslookup <host>
- Fix /etc/resolv.conf or network security groups so the nameserver answers from every node
- Add stable cluster hosts to /etc/hosts when DNS is unreliable
- If hadoop.security.dns.interface/nameserver are set, verify the pair points at a working resolver
Defensive patterns
Strategy: retry
Validate before calling
boolean resolvable(String host) {
try {
java.security.SecurityUtil; // noop
java.net.InetAddress.getByName(host);
return true;
} catch (java.net.UnknownHostException e) {
return false;
}
} Try / catch
int attempts = 0;
while (true) {
try {
principal = SecurityUtil.getServerPrincipal(principalConfig, addr);
break;
} catch (UnknownHostException e) {
if (++attempts >= 3 || !e.getMessage().startsWith("Error resolving host")) throw e;
// transient resolver failure: back off and retry after DNS recovers
Thread.sleep(attempts * 1000L);
}
} Prevention
- Pre-resolve cluster hostnames at startup and fail fast with a clear message
- Maintain /etc/hosts entries for critical cluster hosts as a DNS fallback
- Monitor DNS latency from cluster nodes so resolver degradation is visible
When it happens
Trigger: Host resolution through the cached resolver failing for infrastructure reasons while resolving a server host, e.g. during SecurityUtil.getServerPrincipal(principal, addr) with _HOST substitution: DNS server unreachable, resolver timeouts under load, or runtime exceptions from the DNS layer.
Common situations: Broken /etc/resolv.conf, firewall blocking DNS egress, cloud VPC DNS flakiness, or heavy load causing resolver timeouts on cluster nodes.
Related errors
- Error writing metric to StatsD
- Can't replace _HOST pattern since client address is null
- hadoop.security.dns.nameserver requires hadoop.security.dns.
- Unresolved host: {}
- S14
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/80d8edec690c1b6e.
Report an issue: GitHub.