Strovent SystemsSign in
Reference

SSH "client_loop: send disconnect: Broken pipe"

What "client_loop: send disconnect: Broken pipe" means, how it differs from "Timeout, server not responding", and how to keep sessions alive.

client_loop: send disconnect: Broken pipe

This is the last line of an OpenSSH session that ended while the network connection underneath it was already gone. It is a symptom, not the cause.

What the message means

When an OpenSSH client finishes a session, it sends the server one last SSH message that says "disconnected by user", and waits until that message is written to the connection. The text before the colons names the step that failed (client_loop is the client's main loop, and send disconnect is that last step). "Broken pipe" is the operating system's error text for a write to a connection that the other end, or something in between, has closed or lost.

So by the time the client tried to say goodbye, the TCP connection was dead. Typical reasons:

  • The server, a firewall or a NAT device dropped an idle connection.
  • The device changed networks or went to sleep, for example Wi-Fi to cellular.
  • The server rebooted, or sshd was restarted or killed.

It is different from "Timeout, server not responding"

Timeout, server example.com not responding.

This one comes from the client's server-alive check. With ServerAliveInterval set, the client sends a request through the encrypted channel after that many seconds without data. When more than ServerAliveCountMax such requests (default 3) go unanswered, the client exits. With an interval of 15 and the default count, it gives up after about 45 seconds.

The two messages can both occur on a flaky link, but the first says the connection was already broken when the session ended, and the second says the client noticed silence and gave up.

What to do

  1. Reconnect. The old session is gone. Anything running in it without tmux, screen or nohup was probably ended by the server when it lost the connection.
  2. Send keep-alive traffic if an idle gap is the cause. Add ServerAliveInterval to the host's SSH settings and see SSH keep-alives and idle timeouts for the server-side counterpart.
  3. Check the network path: another network, a VPN that reconnects, or a router with a short idle timeout.
  4. Look at the server. If it logs a restart at the same time, that is the cause.
  5. Use Mosh if your network changes often. A Mosh session survives a lost connection and an IP change: see Mosh.

See also Connection abort, reset and timed-out errors and SSH banner exchange errors.

Sources

Spotted a mistake? Email [email protected].