apache/hadoop · error · IOException

Could not read from stream

Error message

Could not read from stream

What it means

Error "Could not read from stream" thrown in apache/hadoop.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketInputStream.java:124

   * @throws IOException raised on errors performing I/O.
   */
  public SocketInputStream(Socket socket) throws IOException {
    this(socket.getChannel(), socket.getSoTimeout());
  }
  
  @Override
  public int read() throws IOException {
    /* Allocation can be removed if required.
     * probably no need to optimize or encourage single byte read.
     */
    byte[] buf = new byte[1];
    int ret = read(buf, 0, 1);
    if (ret > 0) {
      return (int)(buf[0] & 0xff);
    }
    if (ret != -1) {
      // unexpected
      throw new IOException("Could not read from stream");
    }
    return ret;
  }

  @Override
  public int read(byte[] b, int off, int len) throws IOException {
    return read(ByteBuffer.wrap(b, off, len));
  }

  @Override
  public synchronized void close() throws IOException {
    /* close the channel since Socket.getInputStream().close()
     * closes the socket.
     */
    reader.channel.close();
    reader.close();
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Check that the remote peer did not close the connection prematurely; retry the read or reconnect the socket.
  2. Verify network stability between client and server and inspect server logs for errors that caused it to close the stream.
  3. Increase the socket timeout (e.g. dfs.socket.timeout) if the read fails under heavy load.

When it happens

Trigger: Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/SocketInputStream.java:124 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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