apache/hadoop · error · IllegalArgumentException
Unable to determine service address for namenode '{}'
Error message
Unable to determine service address for namenode '{}' What it means
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.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/NNHAServiceTarget.java:76
private String nsId;
private boolean autoFailoverEnabled;
/**
* Create a NNHAServiceTarget for a namenode.
* Look up addresses from configuration.
*
* @param conf HDFS configuration.
* @param nsId nsId of this nn.
* @param nnId nnId of this nn.
*/
public NNHAServiceTarget(Configuration conf,
String nsId, String nnId) {
initializeNnConfig(conf, nsId, nnId);
String serviceAddr =
DFSUtil.getNamenodeServiceAddr(targetConf, nsId, nnId);
if (serviceAddr == null) {
throw new IllegalArgumentException(
"Unable to determine service address for namenode '" + nnId + "'");
}
this.addr = NetUtils.createSocketAddr(serviceAddr,
HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT);
String lifelineAddrStr =
DFSUtil.getNamenodeLifelineAddr(targetConf, nsId, nnId);
this.lifelineAddr = (lifelineAddrStr != null) ?
NetUtils.createSocketAddr(lifelineAddrStr) : null;
initializeFailoverConfig();
}
/**
* Create a NNHAServiceTarget for a namenode.
* Addresses are provided so we don't need to lookup the config.
*View on GitHub (pinned to 2add963021)
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.
Example fix
<!-- before --> <property><name>dfs.ha.namenodes.mycluster</name><value>nn1,nn2</value></property> <!-- no dfs.namenode.rpc-address.* keys -> Unable to determine service address --> <!-- after --> <property><name>dfs.ha.namenodes.mycluster</name><value>nn1,nn2</value></property> <property><name>dfs.namenode.rpc-address.mycluster.nn1</name><value>nn1-host:8020</value></property> <property><name>dfs.namenode.rpc-address.mycluster.nn2</name><value>nn2-host:8020</value></property>
Defensive patterns
Strategy: validation
Validate before calling
String svc = DFSUtil.getNamenodeServiceAddr(conf, nsId, nnId);
if (svc == null) {
throw new IllegalStateException("Neither dfs.namenode.servicerpc-address."
+ nsId + "." + nnId + " nor dfs.namenode.rpc-address." + nsId + "." + nnId
+ " is set; refusing to build NNHAServiceTarget");
}
NNHAServiceTarget target = new NNHAServiceTarget(conf, nsId, nnId); Try / catch
try {
NNHAServiceTarget t = new NNHAServiceTarget(conf, nsId, nnId);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("service address")) {
throw new IllegalStateException("Missing dfs.namenode.rpc-address." + nsId
+ "." + nnId + " on this host; sync the full HA hdfs-site.xml", e);
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unable to determine the name service ID.
- Configuration dfs.namenode.rpc-address must be suffixed with
- Unable to determine the name service ID. This is an HA confi
- No fencer configured for {}
- {} does not support method msync
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/a8ed7d48f81d5bfc.
Report an issue: GitHub.