Keep a terminal session running on iPhone when you lose signal

, The Lumzoi team

Short answer: the shell has to live on the Mac, not in the connection. Run it inside tmux (or use Mosh plus tmux), or use Lumzoi Desk, whose shells belong to a session on the Mac and keep running when your iPhone disconnects. When you reconnect, they come back with their output.

Why the command stops

When you SSH into your Mac from your phone, the shell is a child of that SSH connection. iOS pauses apps in the background within seconds, and mobile networks drop. When the connection goes, the Mac ends the shell, and whatever was running in it: a build, a download, an AI agent halfway through a task.

Fix 1: tmux

tmux runs your shells in a server on the Mac. You attach to it over SSH, and when the connection drops, the shells carry on.

tmux new -s work      # start a session named "work"
# ...run your command, then lose signal or close the app...
tmux attach -t work   # after reconnecting: everything is still there

It’s reliable and free. The cost is discipline: you have to start tmux every time, before the command. Forget once and you’re back to square one. You also need SSH access to the Mac from outside your home network, which usually means port forwarding on your router or a VPN.

Fix 2: Mosh

Mosh keeps a connection alive across network changes and sleep, and is designed for flaky mobile links. It still needs to be installed on the Mac, a range of UDP ports open, and it doesn’t keep a scrollback of what happened while you were gone, which is why people pair it with tmux.

Fix 3: shells that belong to a session

Lumzoi Desk opens shells on your Mac through its own connection, so there’s no SSH server to turn on and no port to forward. Each shell belongs to your device’s session on the Mac, not to the connection:

  • Close the app, lose signal or switch from Wi-Fi to mobile data: the shells keep running.
  • Open the session again: every shell comes back as a tab, with what it printed while you were away.
  • Sessions are kept for up to 7 days after you leave, or until you end them.
  • A key row adds Esc, Tab, Control and the arrows; on iPad, a hardware keyboard works as expected.

It works through hotel Wi-Fi, office firewalls and phone hotspots, connecting directly when it can and through a relay when it can’t, encrypted end to end.

What none of these survive

A restart of the Mac. tmux, Mosh and Lumzoi Desk all keep shells alive across disconnects, but if the Mac restarts, its processes stop. For jobs that must outlive a reboot, use a proper service (launchd), and keep the Mac from sleeping while the work runs.

More about the terminal on iPhone

All posts