Skip to content
MtrXTools

Broken pipe

Wrote to a connection or pipe that was already closed

Seen in Linux and macOS (EPIPE, errno 32), shells and pipelines, ssh, rsync

The program wrote to a socket or pipe after the other end had already closed it.

Common causes

  • The remote side closed the connection (timeout, crash or restart) while this side was still sending.
  • An idle connection was dropped by a firewall, load balancer or NAT, and the next write failed; common with idle SSH sessions.
  • In a shell pipeline, the reading command exited early (for example `| head`), which is usually harmless.

How to fix it

  1. Check the peer's logs for why it closed the connection, such as size limits or idle timeouts.
  2. For idle connections, enable keepalives: `ServerAliveInterval 60` in ~/.ssh/config, or TCP keepalive in the application.
  3. Handle the error and reconnect instead of crashing, and keep client idle timeouts shorter than the server's or load balancer's.

Got a different message? Paste it into the error explainer.

Related errors

All 19 Network errors