apache/hadoop · error · IOException

Missing both 'ipAddr' and 'name' in server response.

Error message

Missing both 'ipAddr' and 'name' in server response.

What it means

JsonUtilClient.toDatanodeInfo requires either the modern ipAddr field or the old 1.x/0.23.x name field to identify a DataNode. If both keys are absent from a datanode JSON object, the client cannot construct the address needed to transfer blocks and throws this IOException.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java:337

    // If any one of the two is missing, an exception needs to be thrown.

    // Handle the case of old servers (1.x, 0.23.x) sending 'name' instead
    //  of ipAddr and xferPort.
    String ipAddr = getString(m, "ipAddr", null);
    int xferPort = getInt(m, "xferPort", -1);
    if (ipAddr == null) {
      String name = getString(m, "name", null);
      if (name != null) {
        int colonIdx = name.indexOf(':');
        if (colonIdx > 0) {
          ipAddr = name.substring(0, colonIdx);
          xferPort = Integer.parseInt(name.substring(colonIdx +1));
        } else {
          throw new IOException(
              "Invalid value in server response: name=[" + name + "]");
        }
      } else {
        throw new IOException(
            "Missing both 'ipAddr' and 'name' in server response.");
      }
      // ipAddr is non-null & non-empty string at this point.
    }

    // Check the validity of xferPort.
    if (xferPort == -1) {
      throw new IOException(
          "Invalid or missing 'xferPort' in server response.");
    }

    // TODO: Fix storageID
    return new DatanodeInfoBuilder().setIpAddr(ipAddr)
        .setHostName((String) m.get("hostName"))
        .setDatanodeUuid((String) m.get("storageID")).setXferPort(xferPort)
        .setInfoPort(((Number) m.get("infoPort")).intValue())
        .setInfoSecurePort(getInt(m, "infoSecurePort", 0))
        .setIpcPort(((Number) m.get("ipcPort")).intValue())

View on GitHub (pinned to 2add963021)

Solutions

  1. Verify the URL is a real WebHDFS NameNode endpoint, normally http(s)://namenode:port/webhdfs/v1/..., rather than a gateway or management API.
  2. Upgrade the old server or use a client release matching the server response schema.
  3. Fix a custom proxy or mock so datanode objects include ipAddr and xferPort.
  4. Capture the raw response and inspect its datanode entries before retrying, because this is a schema error and retrying unchanged will fail again.

Example fix

// before
FileSystem fs = FileSystem.get(new URI("webhdfs://gateway:9870"), conf);
RemoteIterator<LocatedFileStatus> files = fs.listFiles(path, true);

// after: use the NameNode WebHDFS endpoint directly
FileSystem fs = FileSystem.get(new URI("webhdfs://namenode:9870"), conf);
RemoteIterator<LocatedFileStatus> files = fs.listFiles(path, true);
Defensive patterns

Strategy: try-catch

Try / catch

try {
  return fs.getFileBlockLocations(path, start, len);
} catch (IOException e) {
  if (e.getMessage() != null && e.getMessage().contains("Missing both 'ipAddr' and 'name'")) {
    throw new IllegalStateException("Endpoint did not return WebHDFS-compatible datanode objects", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: Any API whose WebHDFS response contains datanode locations, such as open, getFileBlockLocations, or listLocatedStatus, receives a datanode map with neither ipAddr nor name. This generally indicates a non-WebHDFS endpoint, a proxy-generated JSON body, or a server/client version that does not share a response schema.

Common situations: Calling a REST service that mimics WebHDFS but omits DataNode fields; a reverse proxy returning its own JSON error object with HTTP 200; a mock server built from a different Hadoop version; a partially upgraded cluster.

Related errors


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