apache/hadoop · error · IOException
Incomplete HDFS URI, no host: {}
Error message
Incomplete HDFS URI, no host: {} What it means
After the scheme check, the Hdfs (AbstractFileSystem) constructor requires a hostname: URI.getHost() must be non-null or it throws IOException("Incomplete HDFS URI, no host: " + theUri). Authority-less URIs such as hdfs:///path (empty authority) cannot be used with the FileContext-level Hdfs impl — an HA nameservice ID as the host is fine because it is still a host.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/fs/Hdfs.java:88
/**
* This constructor has the signature needed by
* {@link AbstractFileSystem#createFileSystem(URI, Configuration)}
*
* @param theUri which must be that of Hdfs
* @param conf configuration
* @throws IOException
*/
Hdfs(final URI theUri, final Configuration conf) throws IOException, URISyntaxException {
super(theUri, HdfsConstants.HDFS_URI_SCHEME, true,
HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT);
if (!theUri.getScheme().equalsIgnoreCase(HdfsConstants.HDFS_URI_SCHEME)) {
throw new IllegalArgumentException("Passed URI's scheme is not for Hdfs");
}
String host = theUri.getHost();
if (host == null) {
throw new IOException("Incomplete HDFS URI, no host: " + theUri);
}
this.dfs = new DFSClient(theUri, conf, getStatistics());
}
@Override
public int getUriDefaultPort() {
return HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT;
}
@Override
public HdfsDataOutputStream createInternal(Path f,
EnumSet<CreateFlag> createFlag, FsPermission absolutePermission,
int bufferSize, short replication, long blockSize, Progressable progress,
ChecksumOpt checksumOpt, boolean createParent) throws IOException {
final DFSOutputStream dfsos = dfs.primitiveCreate(getUriPath(f),
absolutePermission, createFlag, createParent, replication, blockSize,View on GitHub (pinned to 2add963021)
Solutions
- Set an explicit authority: hdfs://namenode:8020, or for HA hdfs://<nameservice-id>
- Fix fs.defaultFS in core-site.xml to include the host or nameservice ID
- Build URIs programmatically with new URI("hdfs", host, path, null) instead of string concatenation that drops the //host part
Example fix
// before
URI u = URI.create("hdfs:///user/me/in.txt"); // no host
FileContext fc = FileContext.getFileContext(u, conf);
// after
URI u = URI.create("hdfs://nn1.example.com:8020/user/me/in.txt");
FileContext fc = FileContext.getFileContext(u, conf); Defensive patterns
Strategy: validation
Validate before calling
URI u = URI.create(defaultFs);
if ("hdfs".equalsIgnoreCase(u.getScheme()) && u.getHost() == null) {
throw new IllegalArgumentException(
"fs.defaultFS lacks a host/nameservice: " + defaultFs);
} Type guard
static boolean hasHdfsAuthority(URI u) {
return "hdfs".equalsIgnoreCase(u.getScheme()) && u.getHost() != null;
} Try / catch
try {
Hdfs h = (Hdfs) AbstractFileSystem.createFileSystem(u, conf);
} catch (IOException e) {
if (e.getMessage().startsWith("Incomplete HDFS URI")) {
// add hdfs://host:port or hdfs://nameservice-id
}
} Prevention
- Always set fs.defaultFS with a host or HA nameservice ID
- Build URIs with new URI(scheme, host, path, fragment) instead of string concat
- Reject authority-less hdfs:/// URIs at configuration load time
When it happens
Trigger: FileContext.getFileContext(...) / create with a defaultFS or URI of 'hdfs:///' or 'hdfs:///user/x' (no authority); URIs built with URI.create("hdfs:///path") or a port-only authority like 'hdfs://:8020'.
Common situations: fs.defaultFS configured without a host or nameservice; scripts stripping the authority when constructing paths; porting code from the FileSystem API (which resolves the default authority) to FileContext (which requires it in the URI).
Related errors
- Passed URI's scheme is not for Hdfs
- Bad configuration of hadoop.security.key.provider.path at ${
- Uri without authority: {uri}
- Wrong FS: {path}, expected: {this.getUri()}
- No scheme in default FS: ${uri}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/4ae416becd222137.
Report an issue: GitHub.