apache/hadoop · error · DisallowedDatanodeException

Datanode denied communication with namenode because hostname

Error message

Datanode denied communication with namenode because hostname cannot be resolved (ip={ip}, hostname={hostname}): {nodeReg}

What it means

Thrown as DisallowedDatanodeException from DatanodeManager.registerDatanode when the NN (with dfs.namenode.datanode.registration.ip-hostname-check=true, default) receives a registration from an address whose reverse-DNS lookup produces a hostname that cannot itself be resolved back. The check prevents datanodes whose DNS is broken from causing repeated expensive lookup failures later; registration is denied with the ip/hostname pair.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java:1201

   * @throws DisallowedDatanodeException if the registration request is
   *    denied because the datanode does not match includes/excludes
   * @throws UnresolvedTopologyException if the registration request is 
   *    denied because resolving datanode network location fails.
   */
  public void registerDatanode(DatanodeRegistration nodeReg)
      throws DisallowedDatanodeException, UnresolvedTopologyException {
    InetAddress dnAddress = Server.getRemoteIp();
    if (dnAddress != null) {
      // Mostly called inside an RPC, update ip and peer hostname
      String hostname = dnAddress.getHostName();
      String ip = dnAddress.getHostAddress();
      if (checkIpHostnameInRegistration && !isNameResolved(dnAddress)) {
        // Reject registration of unresolved datanode to prevent performance
        // impact of repetitive DNS lookups later.
        final String message = "hostname cannot be resolved (ip="
            + ip + ", hostname=" + hostname + ")";
        LOG.warn("Unresolved datanode registration: " + message);
        throw new DisallowedDatanodeException(nodeReg, message);
      }
      // update node registration with the ip and hostname from rpc request
      nodeReg.setIpAddr(ip);
      nodeReg.setPeerHostName(hostname);
    }
    
    try {
      nodeReg.setExportedKeys(blockManager.getBlockKeys());
  
      // Checks if the node is not on the hosts list.  If it is not, then
      // it will be disallowed from registering. 
      if (!hostConfigManager.isIncluded(nodeReg)) {
        throw new DisallowedDatanodeException(nodeReg);
      }
        
      NameNode.stateChangeLog.info("BLOCK* registerDatanode: from "
          + nodeReg + " storage " + nodeReg.getDatanodeUuid());
  

View on GitHub (pinned to 2add963021)

Solutions

  1. Fix DNS/hosts so the datanode's IP reverse-resolves AND the resulting hostname forward-resolves to that IP; verify on the NN host: `nslookup <ip>` then `nslookup <hostname>`
  2. For clusters not using DNS, add consistent forward+reverse entries for all DNs in /etc/hosts on the NameNode
  3. As a documented workaround, set dfs.namenode.datanode.registration.ip-hostname-check=false in hdfs-site.xml (accept the DNS lookup cost) and restart NN
  4. In cloud environments, provide proper PTR records or use the topology/rack script that tolerates unresolved names

Example fix

<!-- before: PTR record missing, DN registration denied -->
<!-- NN log: Unresolved datanode registration: hostname cannot be resolved (ip=10.0.0.5, hostname=ip-10-0-0-5.ec2.internal) -->

<!-- after: disable the check when DNS is not authoritative -->
<property>
  <name>dfs.namenode.datanode.registration.ip-hostname-check</name>
  <value>false</value>
</property>
Defensive patterns

Strategy: validation

Validate before calling

// On the NameNode host, verify forward+reverse consistency for each DN
InetAddress byName = InetAddress.getByName("dn5.example.com");
InetAddress byAddr = InetAddress.getByName("10.0.0.5");
if (!byName.getHostAddress().equals("10.0.0.5")
    || !byAddr.getCanonicalHostName().equals("dn5.example.com")) {
  throw new IllegalStateException("DNS/hosts mismatch for dn5 — fix before starting DN");
}

Prevention

When it happens

Trigger: Datanode registers; Server.getRemoteIp() reverse-maps to a hostname (e.g., from /etc/hosts or PTR) that then fails forward resolution (isNameResolved false) — misconfigured DNS/PTR records, stale /etc/hosts entries, hostname pointing to 127.0.x, or cloud instances without proper reverse DNS.

Common situations: Cloud/VM deployments without PTR records; /etc/hosts mapping hostname to wrong/loopback IP; split DNS after network changes; containers where the NN resolves a container-internal name.

Related errors


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