apache/hadoop · error · HttpGetFailedException

Image transfer servlet at " + url + " failed with status cod

Error message

Image transfer servlet at " + url + " failed with status code " + connection.getResponseCode() + "\nResponse message:\n" + connection.getResponseMessage()

What it means

Util.doGetUrl fetches from the NameNode's GetImageServlet (image transfer) for checkpoint/bootstrap and throws HttpGetFailedException when the HTTP status is not 200. The exception records the URL, status code and response message, and exposes the code programmatically via getResponseCode(), so the fix depends on the code: 404 wrong endpoint, 401/403 authentication, 5xx server-side servlet failure.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/Util.java:171

  /**
   * Downloads the files at the specified url location into destination
   * storage.
   */
  public static MD5Hash doGetUrl(URL url, List<File> localPaths,
      Storage dstStorage, boolean getChecksum, int timeout,
      DataTransferThrottler throttler) throws IOException {
    HttpURLConnection connection;
    try {
      connection = (HttpURLConnection)
          connectionFactory.openConnection(url, isSpnegoEnabled);
    } catch (AuthenticationException e) {
      throw new IOException(e);
    }

    setTimeout(connection, timeout);

    if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
      throw new HttpGetFailedException("Image transfer servlet at " + url +
              " failed with status code " + connection.getResponseCode() +
              "\nResponse message:\n" + connection.getResponseMessage(),
          connection);
    }

    long advertisedSize;
    String contentLength = connection.getHeaderField(CONTENT_LENGTH);
    if (contentLength != null) {
      advertisedSize = Long.parseLong(contentLength);
    } else {
      throw new IOException(CONTENT_LENGTH + " header is not provided " +
          "by the namenode when trying to fetch " + url);
    }
    MD5Hash advertisedDigest = parseMD5Header(connection);
    String fsImageName = connection
        .getHeaderField(ImageServlet.HADOOP_IMAGE_EDITS_HEADER);
    InputStream stream = connection.getInputStream();

View on GitHub (pinned to 2add963021)

Solutions

  1. Reproduce with curl -v on the exact URL from the message and inspect the status and body
  2. Verify dfs.namenode.http-address points at the active NameNode and is reachable from the checkpointer host
  3. On Kerberized clusters, confirm SPNEGO/keytab setup on both NameNode and checkpointer (verify with curl --negotiate -u :)
  4. Check the NameNode log at the same timestamp for the matching GetImageServlet error
Defensive patterns

Strategy: retry

Validate before calling

HttpURLConnection c = (HttpURLConnection) new URL(checkpointUrl).openConnection();
c.setConnectTimeout(5000);
c.setRequestMethod("HEAD");
if (c.getResponseCode() != 200) {
  throw new IOException("checkpoint endpoint unhealthy (" + c.getResponseCode()
      + "): " + checkpointUrl);
}

Try / catch

try {
  Util.doGetUrl(url, dst, timeout, false, factory, throttler);
} catch (HttpGetFailedException e) {
  switch (e.getResponseCode()) {
    case 401: case 403: // fix SPNEGO/keytab config; do not retry
    case 404:           // wrong dfs.namenode.http-address; do not retry
    default:            // 5xx: backoff-and-retry a bounded number of times
  }
}

Prevention

When it happens

Trigger: Secondary/Backup/Standby NameNode fetching an fsimage with a wrong dfs.namenode.http-address (404); Kerberos/SPNEGO not configured between checkpointer and NN (401/403); GetImageServlet rejecting malformed query params; NN still starting or in a bad state (5xx); a proxy in front of the NN mangling the request.

Common situations: Misconfigured dfs.namenode.http-address or dfs.namenode.backup.address; Kerberized cluster where the 2NN lacks a keytab/krb5.conf; firewall or redirect through a proxy; NN restarting while a checkpoint fires.

Related errors


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