apache/hadoop · error · IllegalArgumentException

Invalid URI for NameNode address (check %s): %s has no autho

Error message

Invalid URI for NameNode address (check %s): %s has no authority.

What it means

DFSUtilClient.getNNAddress(URI) converts the default filesystem URI into a NameNode socket address and requires an authority (host:port or HA logical name) component. When the URI carries none — e.g., 'hdfs:///' or 'hdfs:' — it throws IllegalArgumentException('Invalid URI for NameNode address (check fs.defaultFS): ... has no authority.'), explicitly naming fs.defaultFS (FileSystem.FS_DEFAULT_NAME_KEY) as the property to correct.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSUtilClient.java:886

  }

  public static InetSocketAddress getNNAddress(String address) {
    return NetUtils.createSocketAddr(address,
        HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT);
  }

  public static InetSocketAddress getNNAddress(Configuration conf) {
    URI filesystemURI = FileSystem.getDefaultUri(conf);
    return getNNAddressCheckLogical(conf, filesystemURI);
  }

  /**
   * @return address of file system
   */
  public static InetSocketAddress getNNAddress(URI filesystemURI) {
    String authority = filesystemURI.getAuthority();
    if (authority == null) {
      throw new IllegalArgumentException(String.format(
          "Invalid URI for NameNode address (check %s): %s has no authority.",
          FileSystem.FS_DEFAULT_NAME_KEY, filesystemURI.toString()));
    }
    if (!HdfsConstants.HDFS_URI_SCHEME.equalsIgnoreCase(
        filesystemURI.getScheme())) {
      throw new IllegalArgumentException(String.format(
          "Invalid URI for NameNode address (check %s): " +
          "%s is not of scheme '%s'.", FileSystem.FS_DEFAULT_NAME_KEY,
          filesystemURI.toString(), HdfsConstants.HDFS_URI_SCHEME));
    }
    return getNNAddress(authority);
  }

  /**
   * Get the NN address from the URI. If the uri is logical, default address is
   * returned. Otherwise return the DNS-resolved address of the URI.
   *
   * @param conf configuration

View on GitHub (pinned to 2add963021)

Solutions

  1. Set fs.defaultFS to a fully qualified authority: hdfs://nn1.example.com:8020 or the HA logical name hdfs://mycluster (with dfs.nameservices configured).
  2. Validate the configuration at startup: assert FileSystem.getDefaultUri(conf).getAuthority() != null with a clear startup error.
  3. If the code path must work without an NN, branch before calling getNNAddress(URI) rather than relying on the exception.
  4. For HA, double-check dfs.nameservices and dfs.ha.namenodes.<id> match the logical authority you configured.

Example fix

<!-- before: core-site.xml -->
<property><name>fs.defaultFS</name><value>hdfs:///</value></property>

<!-- after -->
<property><name>fs.defaultFS</name><value>hdfs://mycluster</value></property>
Defensive patterns

Strategy: validation

Validate before calling

URI defaultUri = FileSystem.getDefaultUri(conf);
if (defaultUri.getAuthority() == null) {
  throw new IllegalStateException(
      "fs.defaultFS must carry a NameNode authority, got: " + defaultUri);
}
return DFSUtilClient.getNNAddress(defaultUri);

Type guard

boolean hasAuthority = uri.getAuthority() != null;

Try / catch

try {
  return DFSUtilClient.getNNAddress(uri);
} catch (IllegalArgumentException e) {
  // config error: fail startup with an actionable message pointing at fs.defaultFS
  throw new ConfigurationException("Fix fs.defaultFS (hdfs://host:port): " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: fs.defaultFS (or a URI handed directly to getNNAddress(URI)) lacking an authority: 'hdfs:///' written in core-site.xml, URIs built with URI.create("hdfs://"), or property placeholders expanding to empty at load time.

Common situations: Incomplete or templated core-site.xml (missing host after hdfs://); cluster-agnostic test configurations using a bare scheme; configuration files shipped with placeholder values like ${nameNodeHost} that never get substituted.

Related errors


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