apache/hadoop · error · IllegalArgumentException

No scheme in default FS: ${uri}

Error message

No scheme in default FS: ${uri}

What it means

FileSystem.getDefaultUri(Configuration) reads fs.defaultFS (falling back to the legacy default), passes it through fixName (which only repairs the legacy 'local' and leading-'/' forms), and requires the resulting URI to have a scheme. A value like 'namenode:8020' parses as a URI with a null scheme, so the method throws IllegalArgumentException - the config must be fully qualified, e.g. hdfs://namenode:8020.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java:301

   * Returns the configured FileSystem implementation.
   * @param conf the configuration to use
   * @return FileSystem.
   * @throws IOException If an I/O error occurred.
   */
  public static FileSystem get(Configuration conf) throws IOException {
    return get(getDefaultUri(conf), conf);
  }

  /**
   * Get the default FileSystem URI from a configuration.
   * @param conf the configuration to use
   * @return the uri of the default filesystem
   */
  public static URI getDefaultUri(Configuration conf) {
    URI uri =
        URI.create(fixName(conf.getTrimmed(FS_DEFAULT_NAME_KEY, DEFAULT_FS)));
    if (uri.getScheme() == null) {
      throw new IllegalArgumentException("No scheme in default FS: " + uri);
    }
    return uri;
  }

  /**
   * Set the default FileSystem URI in a configuration.
   * @param conf the configuration to alter
   * @param uri the new default filesystem uri
   */
  public static void setDefaultUri(Configuration conf, URI uri) {
    conf.set(FS_DEFAULT_NAME_KEY, uri.toString());
  }

  /** Set the default FileSystem URI in a configuration.
   * @param conf the configuration to alter
   * @param uri the new default filesystem uri
   */
  public static void setDefaultUri(Configuration conf, String uri) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Set fs.defaultFS to a fully-qualified URI: hdfs://namenode:8020 (or file:/// for local)
  2. Print the effective value at runtime: conf.get("fs.defaultFS") - look for unresolved placeholders or truncation
  3. Replace legacy fs.default.name forms ('local', '/path') with explicit file:/// values

Example fix

<!-- before -->
<property><name>fs.defaultFS</name><value>namenode:8020</value></property>

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

Strategy: validation

Validate before calling

String raw = conf.getTrimmed("fs.defaultFS", "file:///");
URI u = URI.create(raw);
if (u.getScheme() == null) {
  throw new IllegalArgumentException(
      "fs.defaultFS must include a scheme (e.g. hdfs://host:8020): " + raw);
}
FileSystem fs = FileSystem.get(conf);

Prevention

When it happens

Trigger: Calling FileSystem.get(conf), FileSystem.getDefaultUri(conf), or any API that resolves the default filesystem while fs.defaultFS (or legacy fs.default.name) is set to a scheme-less value such as 'host:9000' or a bare hostname.

Common situations: Hand-edited or templated core-site.xml where the hdfs:// prefix was dropped or a ${...} variable failed to resolve; configs ported from host:port-style systems; XML where the property value got mangled.

Related errors


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