apache/hadoop · error · HttpGetFailedException
Fetch of url failed with status code connection.getResponseC
Error message
Fetch of url failed with status code connection.getResponseCode()\nResponse message:\nconnection.getResponseMessage()
What it means
HttpGetFailedException thrown by the URLLog fetcher inside EditLogFileInputStream: a remote edit log is opened over HTTP (e.g., the EditLogTailer on a standby/observer NameNode pulling segments from a peer's GetImageServlet), and connection.getResponseCode() != 200. The message carries the exact URL, status code, and the server's response message, which identifies the real cause.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileInputStream.java:494
this.url = url;
}
@Override
public InputStream getInputStream() throws IOException {
return SecurityUtil.doAsCurrentUser(
new PrivilegedExceptionAction<InputStream>() {
@Override
public InputStream run() throws IOException {
HttpURLConnection connection;
try {
connection = (HttpURLConnection)
connectionFactory.openConnection(url, isSpnegoEnabled);
} catch (AuthenticationException e) {
throw new IOException(e);
}
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new HttpGetFailedException(
"Fetch of " + url +
" failed with status code " + connection.getResponseCode() +
"\nResponse message:\n" + connection.getResponseMessage(),
connection);
}
String contentLength = connection.getHeaderField(CONTENT_LENGTH);
if (contentLength != null) {
advertisedSize = Long.parseLong(contentLength);
if (advertisedSize <= 0) {
throw new IOException("Invalid " + CONTENT_LENGTH + " header: " +
contentLength);
}
} else {
throw new IOException(CONTENT_LENGTH + " header is not provided " +
"by the server when trying to fetch " + url);
}
View on GitHub (pinned to 2add963021)
Solutions
- Reproduce by hand with the URL from the log: kinit, then curl --negotiate -sv '<getedit URL>' -o /dev/null and read the status/message.
- 404: confirm the segment exists on the source NN (ls current/ or journal report); if simply not ready yet, the tailer retries on its interval -- check edit-lag metrics.
- 401/403: fix SPNEGO (keytab present, dfs.namenode.kerberos.principal/SPN HTTP/nn@REALM, krb5.conf, clock skew).
- 5xx: read the source NN's logs for the servlet failure; fix NN health or version mismatch on GetImageServlet parameters.
Example fix
# before: tailer log shows Fetch of http://nn1:9870/getimage?getedit=1&txid=... failed with status code 404
kinit -kt /etc/security/keytab/nn.keytool nn/nn1@REALM
curl --negotiate -s -o /dev/null -w '%{http_code}\n' 'http://nn1:9870/getimage?getedit=1&txid=1234'
# after: 200 -> segment now available, tailer recovers on next cycle; 403 -> fix SPNEGO Defensive patterns
Strategy: retry
Validate before calling
kinit -kt /etc/security/keytab/nn.keytab nn/nn1@REALM
curl --negotiate -s -o /dev/null -w '%{http_code}\n' "<the exact getedit URL from the NN log>"
# expect 200 before the tailer can succeed; 401/403 -> fix Kerberos, 404 -> segment absent Try / catch
catch (IOException e) {
if (e instanceof HttpGetFailedException h) { // or match on message 'Fetch of '
int code = h.getStatusCode(); // from the exception's connection
if (code == 404) { scheduleRetry(backoff); } // segment not ready / purged
else if (code == 401 || code == 403) { alert("SPNEGO misconfigured"); }
else { retryWithBackoff(); }
} else { throw e; }
} Prevention
- Keep edit-segment retention longer than the standby/tailer's worst-case lag.
- Monitor edit-tail lag metrics and alert before segments disappear.
- Verify SPNEGO setup (keytab, SPN HTTP/host@REALM, krb5.conf, clock skew) after any Kerberos change.
- Point tailers directly at NameNodes, not through proxies that rewrite status codes.
When it happens
Trigger: Opening EditLogFileInputStream on an http(s) URL to the journal endpoint and getting 404 (segment not yet available on that NN or already purged), 401/403 (SPNEGO/Kerberos failure), or 5xx (servlet error on the source NN). Reachable only from NN-internal tailing or tooling that fetches edits over HTTP.
Common situations: Standby tailer lagging until segments were purged; Kerberos keytab/krb5.conf/SPN (HTTP/host@REALM) misconfigured on the tailing side; dfs.namenode.http-address pointing at the wrong host; a firewall or load balancer in the path returning 502/503.
Related errors
- Image transfer servlet at " + url + " failed with status cod
- "Invalid Content-Length header: " + contentLength
- "Content-Length header is not provided by the server when tr
- Image uploading failed, status: %d, url: %s, message: %s
- Unrecognized value '{}' for dfs.http.policy
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/5e1aa09b86f064fe.
Report an issue: GitHub.