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.
Why It Happens
Section titled “Why It Happens”iOS’s app lifecycle works like this:
- Foreground: App runs normally. SSH connections are active.
- Background (brief): When you switch away, the app gets a short window (typically 5-30 seconds) to finish work.
- Suspended: iOS freezes the app’s process. TCP connections time out and die.
- 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.
Mitigations
Section titled “Mitigations”1. Use tmux on the Server (Recommended)
Section titled “1. Use tmux on the Server (Recommended)”tmux keeps your session alive on the server regardless of what happens to the client connection.
Set the Startup Command on your connection to:
tmux new-session -A -s mainThis 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.
2. Enable SSH Keep-Alive
Section titled “2. Enable SSH Keep-Alive”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.
3. Disable Auto-Lock (Temporarily)
Section titled “3. Disable Auto-Lock (Temporarily)”If you need an uninterrupted session:
- Go to iOS Settings > Display & Brightness > Auto-Lock.
- Set to Never while you are actively working.
- Remember to set it back afterward.
This keeps the screen on and ZestSSH in the foreground.
4. Use Guided Access
Section titled “4. Use Guided Access”iOS Guided Access locks the device to a single app:
- Go to iOS Settings > Accessibility > Guided Access and enable it.
- Open ZestSSH and triple-click the side button to start Guided Access.
- The device will stay in ZestSSH until you exit Guided Access.
This prevents accidental app switches but keeps the screen on.
5. Mosh (Desktop Only)
Section titled “5. Mosh (Desktop Only)”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.
What Does NOT Work
Section titled “What Does NOT Work”- 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.
Best Practice for iOS
Section titled “Best Practice for iOS”The most reliable workflow on iOS is:
- Set up tmux on every server you connect to.
- Use
tmux new-session -A -s mainas the startup command. - Accept that connections will drop when you leave the app.
- 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.