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

  1. Resolve the named host manually on the affected node: getent hosts <host> and nslookup <host>
  2. Fix /etc/resolv.conf or network security groups so the nameserver answers from every node
  3. Add stable cluster hosts to /etc/hosts when DNS is unreliable
  4. 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

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


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/80d8edec690c1b6e. Report an issue: GitHub.