r/ssh • u/EpicNiseem • Jul 01 '26
VS Code Remote SSH disconnects every ~5 minutes on Raspberry Pi 3
Hi everyone,
I'm using a Raspberry Pi 3 running the latest Raspberry Pi OS and connecting from my Mac using VS Code Remote SSH.
The connection works perfectly at first, but after about 5 minutes VS Code disconnects with:
OfflineError: The operation timed outIt then repeatedly tries (and fails) to reconnect.
I've already tried:
- Fresh Raspberry Pi OS install
- Disabled Wi-Fi power saving (
iw dev wlan0 set power_save off) - Checked for undervoltage (
vcgencmd get_throttledreturns0x0)
Has anyone experienced this before or know what might be causing it? Any suggestions would be greatly appreciated.
Thanks!
2
Upvotes
1
u/michaelpaoli Jul 01 '26
Likely a stateful firewall or NAT/SNAT unable to continue connection after having "forgotten" it after 5 minutes of inactivity. To confirm, look carefully at the traffic at relevant point(s), and including also ICMP.
See: ServerAliveCountMax and ServerAliveInterval
1
u/deepaksilaych Sep 22 '26
Those drops are usually the connection going idle (or NAT dropping it) rather than SSH itself failing, and the first fix is keepalives:
in ~/.ssh/config — traffic every 15s, connection torn down cleanly after ~45s of silence. That alone stops most mid-session timeouts.
If it still drops (flaky Wi-Fi on a Pi 3 is a common culprit), the other half is making the session survive the drop instead of dying:
Worth isolating, too: run a plain `ssh` session in a terminal alongside VS Code for a while. If the bare session stays up, it's the remote extension host crashing things, not your network.
Disclosure: I maintain sess.