iOS Backgrounding
This is the most important platform-specific page for iOS users. iOS suspends apps after approximately 30 seconds in the background, disconnecting all SSH sessions. This is not a ZestSSH bug — it is a platform restriction that affects every SSH client on iOS.
What Happens
Section titled “What Happens”When you switch to another app or lock your screen on iOS:
- iOS suspends ZestSSH after approximately 30 seconds.
- All active SSH connections are disconnected by the operating system.
- All port forwards and SFTP transfers in progress are terminated.
- Any unsaved work in remote editors (vim, nano, emacs) may be lost if the session is not recovered by the server.
Why It Happens
Section titled “Why It Happens”iOS enforces strict background execution limits to preserve battery life and system resources.
Unlike Android, iOS does not allow apps to maintain persistent network connections in the background without using specific entitlements. The available background modes (audio, location, VoIP, Bluetooth) do not apply to SSH connections.
This is not a ZestSSH limitation. Every SSH client on iOS has this same constraint, including Termius, Prompt, and Blink Shell.
What ZestSSH Does
Section titled “What ZestSSH Does”ZestSSH implements several mitigations to minimize the impact:
Auto-Reconnect
Section titled “Auto-Reconnect”When you return to the app, ZestSSH automatically detects disconnected sessions and reconnects them with exponential backoff. You do not need to manually reconnect — the app handles it transparently.
Session State Preservation
Section titled “Session State Preservation”Your terminal scrollback and local session history are preserved even after a disconnect. When you return, you can see everything that was on screen before the disconnection.
Port Forward Rules
Section titled “Port Forward Rules”Port forward rules are saved persistently and can be configured to auto-activate on reconnect. When a session reconnects, your port forwards resume automatically.
Disconnect Notification
Section titled “Disconnect Notification”When a session disconnects due to backgrounding, a snackbar notification appears to inform you of the disconnection and the automatic reconnect attempt.
Recommended Solutions
Section titled “Recommended Solutions”Use tmux or GNU screen
Section titled “Use tmux or GNU screen”A terminal multiplexer running on the server keeps your session alive regardless of what happens to the SSH connection:
$ tmux new -s workYour session persists on the server even when iOS kills the SSH connection. When ZestSSH reconnects, reattach to your session:
$ tmux attach -t workGNU screen works the same way:
$ screen -S work$ screen -r work # reattach after reconnectUse Mosh (Mobile Shell)
Section titled “Use Mosh (Mobile Shell)”Mosh is specifically designed for mobile and intermittent connections:
$ mosh user@serverMosh handles roaming, intermittent connectivity, and high latency gracefully. It uses UDP instead of TCP, so it can resume instantly after a network change without establishing a new connection. ZestSSH supports Mosh connections natively.
Combine Both
Section titled “Combine Both”For the most resilient setup, use Mosh as the transport layer and tmux on the server:
- Connect via Mosh for resilient transport.
- Run tmux on the server for persistent sessions.
- Even if Mosh’s UDP state expires, tmux keeps your session alive for reattachment.
Why ZestSSH Doesn’t Use Background Workarounds
Section titled “Why ZestSSH Doesn’t Use Background Workarounds”Some apps abuse UIBackgroundModes (such as playing silent audio or using location updates) to keep connections alive in the background. ZestSSH does not do this because:
-
Apple actively rejects apps that misuse these entitlements. Apps caught playing silent audio to maintain connections are removed from the App Store or required to remove the workaround.
-
Battery drain. Background audio or location hacks keep the CPU and radio active, significantly draining battery life — exactly the problem Apple’s background restrictions are designed to prevent.
-
Unreliable. Even these workarounds can fail: iOS may still terminate the app during memory pressure, after an iOS update, or when the system decides the background activity is not legitimate.
-
App Store compliance. ZestSSH prioritizes a reliable, App Store-compliant experience over workarounds that could stop working with any iOS update and risk the app’s listing.
Frequently Asked Questions
Section titled “Frequently Asked Questions”Q: Can ZestSSH keep connections alive in the background on iOS? A: No. iOS does not provide a legitimate background mode for SSH connections. No SSH app on iOS can reliably maintain connections in the background.
Q: Why does Android allow background connections but iOS doesn’t? A: Android’s foreground service API allows apps to run persistent tasks with a visible notification. iOS has no equivalent mechanism for arbitrary network connections.
Q: Will this ever be fixed? A: This depends on Apple adding a background networking entitlement for SSH-type connections. As of iOS 18, no such entitlement exists. The tmux/Mosh approach is the reliable, permanent solution.
Q: My session disconnected and I lost unsaved work. What can I do? A: Use tmux or screen on the server going forward. These tools keep your editor session alive on the server even when the SSH transport drops. Some editors (vim) also maintain swap files that allow recovery.