client_loop: send disconnect: Broken pipe 🐧 Linux

client_loop: send disconnect: Broken pipe (SSH session drops when idle)

The SSH connection was cut — usually an idle timeout on a NAT router, firewall or the server, sometimes a network change.

Seen on: Linux

Meaning

NAT devices and firewalls drop idle TCP connections. Without keep-alives, the next keystroke finds the connection gone. Laptops sleeping or switching Wi-Fi cause the same.

Common causes

  • Idle connection dropped by NAT/firewall
  • Server ClientAliveInterval disconnects idle clients
  • Network change or laptop sleep
  • Server restarted/sshd killed

⚡ Quick fix

  1. Enable keep-alives: ServerAliveInterval 60 in ~/.ssh/config
  2. Use tmux/screen so work survives disconnects
  3. Consider mosh on unreliable networks

Detailed fix by platform

Shell

  1. bash
    # ~/.ssh/config
    Host *
      ServerAliveInterval 60
      ServerAliveCountMax 3

How to diagnose

  1. Timing — After how long idle?
  2. Network — Wi-Fi/VPN changes?
  3. Server — ClientAliveInterval in sshd_config

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.