{"record":{"id":"a8ed7d48f81d5bfc","repo":"apache/hadoop","slug":"unable-to-determine-service-address-for-namenode","errorCode":null,"errorMessage":"Unable to determine service address for namenode '{}'","messagePattern":"Unable to determine service address for namenode '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/NNHAServiceTarget.java","lineNumber":76,"sourceCode":"  private String nsId;\n  private boolean autoFailoverEnabled;\n\n  /**\n   * Create a NNHAServiceTarget for a namenode.\n   * Look up addresses from configuration.\n   *\n   * @param conf          HDFS configuration.\n   * @param nsId          nsId of this nn.\n   * @param nnId          nnId of this nn.\n   */\n  public NNHAServiceTarget(Configuration conf,\n      String nsId, String nnId) {\n    initializeNnConfig(conf, nsId, nnId);\n\n    String serviceAddr =\n        DFSUtil.getNamenodeServiceAddr(targetConf, nsId, nnId);\n    if (serviceAddr == null) {\n      throw new IllegalArgumentException(\n          \"Unable to determine service address for namenode '\" + nnId + \"'\");\n    }\n\n    this.addr = NetUtils.createSocketAddr(serviceAddr,\n        HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT);\n\n    String lifelineAddrStr =\n        DFSUtil.getNamenodeLifelineAddr(targetConf, nsId, nnId);\n    this.lifelineAddr = (lifelineAddrStr != null) ?\n        NetUtils.createSocketAddr(lifelineAddrStr) : null;\n\n    initializeFailoverConfig();\n  }\n\n  /**\n   * Create a NNHAServiceTarget for a namenode.\n   * Addresses are provided so we don't need to lookup the config.\n   *","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/NNHAServiceTarget.java#L58-L94","documentation":"NNHAServiceTarget is the HAAdmin/ZKFC-side description of one NameNode. Its constructor resolves where that NameNode listens via DFSUtil.getNamenodeServiceAddr, which checks dfs.namenode.servicerpc-address.<ns>.<nn> and falls back to dfs.namenode.rpc-address.<ns>.<nn>. If both are absent, the address cannot be determined and an IllegalArgumentException naming the nnId is thrown — every later operation (failover, service state, health checks) needs this address.","triggerScenarios":"Constructing NNHAServiceTarget — directly or via 'hdfs haadmin' operations or ZKFC startup — on a node whose hdfs-site.xml lacks both address keys for the requested nsId/nnId pair; passing a -nn id that is not listed in dfs.ha.namenodes.<ns>; config loaded from a client-only directory without per-NN addresses.","commonSituations":"Admin host has a trimmed-down hdfs-site.xml with only dfs.nameservices and dfs.ha.namenodes but no per-NN rpc addresses; typo in the nn suffix (nn01 vs nn1) so the concatenated key matches nothing; config synced to gateway nodes missing the address block.","solutions":["Add dfs.namenode.rpc-address.<ns>.<nn> (and optionally dfs.namenode.servicerpc-address.<ns>.<nn>) for every nn listed in dfs.ha.namenodes.<ns> on the machine running the tool, then retry.","Verify the ids you pass with -ns/-nn exactly match the configured dfs.ha.namenodes.<ns> entries (case and spelling).","Prefer distributing the NameNodes' full hdfs-site.xml to admin hosts instead of maintaining a hand-trimmed copy."],"exampleFix":"<!-- before -->\n<property><name>dfs.ha.namenodes.mycluster</name><value>nn1,nn2</value></property>\n<!-- no dfs.namenode.rpc-address.* keys -> Unable to determine service address -->\n\n<!-- after -->\n<property><name>dfs.ha.namenodes.mycluster</name><value>nn1,nn2</value></property>\n<property><name>dfs.namenode.rpc-address.mycluster.nn1</name><value>nn1-host:8020</value></property>\n<property><name>dfs.namenode.rpc-address.mycluster.nn2</name><value>nn2-host:8020</value></property>","handlingStrategy":"validation","validationCode":"String svc = DFSUtil.getNamenodeServiceAddr(conf, nsId, nnId);\nif (svc == null) {\n  throw new IllegalStateException(\"Neither dfs.namenode.servicerpc-address.\"\n      + nsId + \".\" + nnId + \" nor dfs.namenode.rpc-address.\" + nsId + \".\" + nnId\n      + \" is set; refusing to build NNHAServiceTarget\");\n}\nNNHAServiceTarget target = new NNHAServiceTarget(conf, nsId, nnId);","typeGuard":null,"tryCatchPattern":"try {\n  NNHAServiceTarget t = new NNHAServiceTarget(conf, nsId, nnId);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"service address\")) {\n    throw new IllegalStateException(\"Missing dfs.namenode.rpc-address.\" + nsId\n        + \".\" + nnId + \" on this host; sync the full HA hdfs-site.xml\", e);\n  }\n  throw e;\n}","preventionTips":["Config-lint HA setups: every id in dfs.ha.namenodes.<ns> must have a dfs.namenode.rpc-address.<ns>.<nn> entry.","Distribute the NameNodes' hdfs-site.xml verbatim to admin hosts rather than maintaining trimmed copies.","Spell -ns/-nn ids exactly as configured; automated checks can diff them against getconf output."],"tags":["hadoop","hdfs","ha","haadmin","rpc-address","configuration"],"backgroundTag":"namenode-rpc-address-missing","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}