{"record":{"id":"80d8edec690c1b6e","repo":"apache/hadoop","slug":"error-resolving-host","errorCode":null,"errorMessage":"Error resolving host ","messagePattern":"Error resolving host ","errorType":"exception","errorClass":"UnknownHostException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java","lineNumber":630,"sourceCode":"                return resolve(key);\n              }\n            });\n      }\n    }\n    protected abstract InetAddress resolve(String host) throws UnknownHostException;\n\n    @Override\n    public InetAddress getByName(String host) throws UnknownHostException {\n      if (cache != null) {\n        try {\n          return cache.get(host);\n        } catch (Exception e) {\n          Throwable cause = e.getCause();\n          if (cause instanceof UnknownHostException) {\n            throw (UnknownHostException) cause;\n          }\n          String message = (cause != null ? cause.getMessage() : \"Unknown error\");\n          throw new UnknownHostException(\"Error resolving host \" + host + \": \" + message);\n        }\n      } else {\n        return resolve(host);\n      }\n    }\n\n    @VisibleForTesting\n    public LoadingCache<String, InetAddress> getCache() {\n      return cache;\n    }\n  }\n  /**\n   * Uses standard java host resolution\n   */\n  static class StandardHostResolver extends CacheableHostResolver {\n\n    StandardHostResolver(long expiryIntervalSecs) {\n      super(expiryIntervalSecs);","sourceCodeStart":612,"sourceCodeEnd":648,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java#L612-L648","documentation":"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.","triggerScenarios":"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.","commonSituations":"Broken /etc/resolv.conf, firewall blocking DNS egress, cloud VPC DNS flakiness, or heavy load causing resolver timeouts on cluster nodes.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"boolean resolvable(String host) {\n  try {\n    java.security.SecurityUtil; // noop\n    java.net.InetAddress.getByName(host);\n    return true;\n  } catch (java.net.UnknownHostException e) {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"int attempts = 0;\nwhile (true) {\n  try {\n    principal = SecurityUtil.getServerPrincipal(principalConfig, addr);\n    break;\n  } catch (UnknownHostException e) {\n    if (++attempts >= 3 || !e.getMessage().startsWith(\"Error resolving host\")) throw e;\n    // transient resolver failure: back off and retry after DNS recovers\n    Thread.sleep(attempts * 1000L);\n  }\n}","preventionTips":["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"],"tags":["dns","network","kerberos","resolution"],"backgroundTag":"dns-resolution-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}