apache/hadoop · error · IllegalArgumentException
Target address cannot be null. (configuration property '${co
Error message
Target address cannot be null. (configuration property '${configName}') What it means
IllegalArgumentException('Target address cannot be null.') from NetUtils.createSocketAddr when the target string is null. When the caller supplies a configName (e.g., 'fs.defaultFS', 'yarn.resourcemanager.scheduler.address'), the message appends '(configuration property ...)' pointing at the property whose value was null. This almost always means the configuration property was never set (or its containing *-site.xml was not loaded), not that null was passed deliberately.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java:236
* @param useCacheIfPresent Whether use cache when create URI
* @return socket addr
*/
public static InetSocketAddress createSocketAddr(String target,
int defaultPort,
String configName,
boolean useCacheIfPresent) {
return createSocketAddr(target, defaultPort, configName, useCacheIfPresent, true);
}
public static InetSocketAddress createSocketAddr(
String target, int defaultPort, String configName,
boolean useCacheIfPresent, boolean isResolved) {
String helpText = "";
if (configName != null) {
helpText = " (configuration property '" + configName + "')";
}
if (target == null) {
throw new IllegalArgumentException("Target address cannot be null." +
helpText);
}
target = target.trim();
boolean hasScheme = target.contains("://");
URI uri = createURI(target, hasScheme, helpText, useCacheIfPresent);
String host = uri.getHost();
int port = uri.getPort();
if (port == -1) {
port = defaultPort;
}
String path = uri.getPath();
if ((host == null) || (port < 0) ||
(!hasScheme && path != null && !path.isEmpty())) {
throw new IllegalArgumentException(
"Does not contain a valid host:port authority: " + target + helpText
);View on GitHub (pinned to 2add963021)
Solutions
- Set the named property in the correct *-site.xml and confirm it is actually loaded (e.g., 'hadoop fs -conf' dump or conf.get in a probe)
- Use the current property key for your Hadoop version (fs.defaultFS since 2.x)
- Guard the call: if (target == null) fail with a clear 'property X is not set' error before calling createSocketAddr
Example fix
// before
InetSocketAddress addr = NetUtils.createSocketAddr(conf.get("fs.defaultFS"), 8020, "fs.defaultFS");
// fs.defaultFS unset -> IllegalArgumentException
// after
String target = conf.get("fs.defaultFS");
if (target == null) throw new IllegalStateException("fs.defaultFS is not set in core-site.xml");
InetSocketAddress addr = NetUtils.createSocketAddr(target, 8020, "fs.defaultFS"); Defensive patterns
Strategy: validation
Validate before calling
String target = conf.get(configName);
if (target == null || target.trim().isEmpty()) {
throw new IllegalStateException(configName + " is not set (or its site xml is not on the classpath)");
} Try / catch
catch (IllegalArgumentException e) { /* 'Target address cannot be null. (configuration property ...)' */ the message names the property: set it and retry; } Prevention
- Assert required address properties are non-null during service initialization
- Use version-correct property keys (fs.defaultFS on 2.x+)
- Add config sanity checks in unit tests for every *-site.xml you ship
When it happens
Trigger: createSocketAddr(conf.get("fs.default.name"), 8020, "fs.default.name") when the property is absent; code deriving an address from HA nameservice resolution that returned null; a service address property empty in the loaded configuration.
Common situations: Wrong or missing *-site.xml on the classpath so conf.get returns null; property renamed between Hadoop versions (fs.default.name vs fs.defaultFS) so the old key is unset; test or tooling code forgetting to set an address before use.
Related errors
- Does not contain a valid host:port authority: ${target} (con
- Unsupported Address type
- Percentage " + percentage + " must be greater than or equal
- Invalid permission '{}' in permission string '{}'
- ACL '{}' not of expected form scheme:id:perm
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/46d83369918cdc82.
Report an issue: GitHub.