{"record":{"id":"6fe6ad8666ffb42f","repo":"apache/hadoop","slug":"datanode-denied-communication-with-namenode-becaus","errorCode":null,"errorMessage":"Datanode denied communication with namenode because hostname cannot be resolved (ip={ip}, hostname={hostname}): {nodeReg}","messagePattern":"Datanode denied communication with namenode because hostname cannot be resolved \\(ip=(.+?), hostname=(.+?)\\): (.+?)","errorType":"exception","errorClass":"DisallowedDatanodeException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java","lineNumber":1201,"sourceCode":"   * @throws DisallowedDatanodeException if the registration request is\n   *    denied because the datanode does not match includes/excludes\n   * @throws UnresolvedTopologyException if the registration request is \n   *    denied because resolving datanode network location fails.\n   */\n  public void registerDatanode(DatanodeRegistration nodeReg)\n      throws DisallowedDatanodeException, UnresolvedTopologyException {\n    InetAddress dnAddress = Server.getRemoteIp();\n    if (dnAddress != null) {\n      // Mostly called inside an RPC, update ip and peer hostname\n      String hostname = dnAddress.getHostName();\n      String ip = dnAddress.getHostAddress();\n      if (checkIpHostnameInRegistration && !isNameResolved(dnAddress)) {\n        // Reject registration of unresolved datanode to prevent performance\n        // impact of repetitive DNS lookups later.\n        final String message = \"hostname cannot be resolved (ip=\"\n            + ip + \", hostname=\" + hostname + \")\";\n        LOG.warn(\"Unresolved datanode registration: \" + message);\n        throw new DisallowedDatanodeException(nodeReg, message);\n      }\n      // update node registration with the ip and hostname from rpc request\n      nodeReg.setIpAddr(ip);\n      nodeReg.setPeerHostName(hostname);\n    }\n    \n    try {\n      nodeReg.setExportedKeys(blockManager.getBlockKeys());\n  \n      // Checks if the node is not on the hosts list.  If it is not, then\n      // it will be disallowed from registering. \n      if (!hostConfigManager.isIncluded(nodeReg)) {\n        throw new DisallowedDatanodeException(nodeReg);\n      }\n        \n      NameNode.stateChangeLog.info(\"BLOCK* registerDatanode: from \"\n          + nodeReg + \" storage \" + nodeReg.getDatanodeUuid());\n  ","sourceCodeStart":1183,"sourceCodeEnd":1219,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java#L1183-L1219","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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>`","For clusters not using DNS, add consistent forward+reverse entries for all DNs in /etc/hosts on the NameNode","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","In cloud environments, provide proper PTR records or use the topology/rack script that tolerates unresolved names"],"exampleFix":"<!-- before: PTR record missing, DN registration denied -->\n<!-- NN log: Unresolved datanode registration: hostname cannot be resolved (ip=10.0.0.5, hostname=ip-10-0-0-5.ec2.internal) -->\n\n<!-- after: disable the check when DNS is not authoritative -->\n<property>\n  <name>dfs.namenode.datanode.registration.ip-hostname-check</name>\n  <value>false</value>\n</property>","handlingStrategy":"validation","validationCode":"// On the NameNode host, verify forward+reverse consistency for each DN\nInetAddress byName = InetAddress.getByName(\"dn5.example.com\");\nInetAddress byAddr = InetAddress.getByName(\"10.0.0.5\");\nif (!byName.getHostAddress().equals(\"10.0.0.5\")\n    || !byAddr.getCanonicalHostName().equals(\"dn5.example.com\")) {\n  throw new IllegalStateException(\"DNS/hosts mismatch for dn5 — fix before starting DN\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain symmetric /etc/hosts or DNS PTR records for all datanodes on NN hosts","In cloud/VDI without reverse DNS, set dfs.namenode.datanode.registration.ip-hostname-check=false deliberately","Never map a DN hostname to 127.0.0.1","Automate DNS sanity checks in node-provisioning pipelines"],"tags":["hdfs","datanode-registration","dns","configuration","namenode"],"backgroundTag":"hostname-resolution-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}