Skip to content

iOS Sessions Disconnecting

iOS aggressively suspends background apps to conserve battery. When ZestSSH moves to the background (you switch to another app, lock the screen, or the display turns off), iOS can suspend the app within seconds, killing active SSH connections.

This is an iOS platform limitation, not a ZestSSH bug. Every SSH client on iOS faces the same constraint.

iOS’s app lifecycle works like this:

  1. Foreground: App runs normally. SSH connections are active.
  2. Background (brief): When you switch away, the app gets a short window (typically 5-30 seconds) to finish work.
  3. Suspended: iOS freezes the app’s process. TCP connections time out and die.
  4. Terminated: If iOS needs memory, it kills the app entirely.

There is no way for a third-party app to keep a persistent TCP connection alive in the background on iOS. Apple restricts this to specific use cases (VoIP, navigation, music) that do not apply to SSH.

tmux keeps your session alive on the server regardless of what happens to the client connection.

Set the Startup Command on your connection to:

Terminal window
tmux new-session -A -s main

This way:

  • When you reconnect after iOS kills the connection, you immediately reattach to your running session.
  • Long-running commands (builds, downloads) continue on the server even when your phone is locked.

See the tmux Workflow guide for detailed setup.

While keep-alive cannot prevent iOS from suspending the app, it helps maintain the connection during brief interruptions (switching apps for a few seconds, checking a notification):

  • Connection editor > Keep-Alive Interval: 15 seconds

This sends periodic packets that prevent the server or intermediate NAT gateways from dropping the idle connection.

If you need an uninterrupted session:

  1. Go to iOS Settings > Display & Brightness > Auto-Lock.
  2. Set to Never while you are actively working.
  3. Remember to set it back afterward.

This keeps the screen on and ZestSSH in the foreground.

iOS Guided Access locks the device to a single app:

  1. Go to iOS Settings > Accessibility > Guided Access and enable it.
  2. Open ZestSSH and triple-click the side button to start Guided Access.
  3. The device will stay in ZestSSH until you exit Guided Access.

This prevents accidental app switches but keeps the screen on.

Mosh (Mobile Shell) is designed for unreliable connections. It uses UDP instead of TCP and handles roaming seamlessly. However, Mosh is currently only available on ZestSSH’s desktop platforms (Windows, macOS, Linux). It is not yet available on iOS.

On desktop, Mosh combined with tmux provides the most resilient setup.

  • Background App Refresh: This is for periodic content updates (like checking email), not for maintaining active network connections.
  • Disabling Low Power Mode: Low Power Mode makes things worse, but disabling it does not fix the fundamental background suspension.
  • VPN apps staying active: VPN apps use a special iOS entitlement (NEVPNManager) that SSH apps cannot use.

The most reliable workflow on iOS is:

  1. Set up tmux on every server you connect to.
  2. Use tmux new-session -A -s main as the startup command.
  3. Accept that connections will drop when you leave the app.
  4. Reconnect when you return --- tmux will restore your session instantly.

This approach works with iOS’s design rather than fighting against it. Your running processes are never interrupted, and reconnection is fast.