Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

Why SSH Connections From a Phone Keep Disconnecting—and How to Fix Them

SSH on a phone can drop during network changes, app suspension, or idle timeouts. Match the fix to the cause: keepalives, Mosh, or tmux.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Phone SSH sessions usually disconnect because the live SSH connection runs over TCP, which can break when your phone changes networks, briefly loses connectivity, or its terminal app is suspended. Keepalives can help with some idle timeouts, but they cannot make SSH roam to a new IP address. For a roaming interactive shell, use Mosh if your server and network support it; to keep a long-running command alive after a drop, run it inside tmux.

First identify when the connection drops

The timing often points to the cause. A normal SSH terminal uses a TCP connection tied to the current network path. A Wi-Fi-to-cellular handoff, a short signal loss, or an address change can interrupt that connection. An idle firewall or NAT timeout is a different problem: it may close a quiet connection even while your phone stays on the same network.

As an Amazon Associate I earn from qualifying purchases.

  • During a network switch or brief loss of signal: the TCP path may have broken. Mosh is designed for interactive sessions that need to tolerate roaming, provided UDP is available.
  • Only after the phone locks or the app goes into the background: test with the terminal app visible. Then check that app’s documented background behavior and the phone’s battery or background restrictions. The details vary by phone, operating-system version, and app.
  • After a repeatable idle period on the same network: investigate SSH keepalive settings and any firewall or NAT idle timeout along the route.
  • The screen stops responding, but there is no clear disconnect: inspect the terminal app’s connection log and, where available, its verbose SSH diagnostics. Blink documents ssh -vvv for increasing SSH diagnostic output; other mobile apps may expose diagnostics differently.

These patterns are clues, not proof. A server log and the specific client’s connection diagnostics can help distinguish an app suspension from a network or server-side timeout.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep SSH alive through some idle periods

For an OpenSSH client, add a host entry like this to ~/.ssh/config on a device or client that supports that configuration:

#1 Best Overall
Sale
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black | Large AMOLED, High-Res Camera, Durable Design, Super Fast Charging, Expandable Storage, Circle to Search, 2025
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.
Host myserver
    ServerAliveInterval 30
    ServerAliveCountMax 3

This is an illustrative starting point, not a universal setting or a promise that the session will survive a network change. OpenBSD’s current ssh_config(5) manual says ServerAliveInterval sends a message through the encrypted channel when no data has arrived from the server for the configured interval. Its default is 0, meaning disabled; ServerAliveCountMax defaults to 3. The manual gives this example: with a 15-second interval and the default count, SSH disconnects after about 45 seconds if the server remains unresponsive.

Client-side keepalives can keep some idle network paths from expiring, depending on intermediary policy, and can help detect an unresponsive path. They do not repair a broken radio link, change the TCP peer address after a handoff, or keep a suspended app running. Phone terminal apps may use different labels for equivalent options, or may not expose them.

Rank #2
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to | Prepaid Smartphone- 6.6" 120Hz Display, 5G , 50MP Quad Pixel Camera, Long-Lasting Battery
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.

Client and server settings are different

OpenSSH’s server-side ClientAliveInterval and ClientAliveCountMax settings are separate from the phone’s client-side ServerAliveInterval and ServerAliveCountMax. Server settings control server-originated liveness checks; changing them is not the same as configuring the phone. Avoid setting very large values just to mask a problem: they can delay detection of a dead connection without fixing its cause.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Mosh when the problem is roaming

Mosh is designed for interactive remote shells over intermittent connections and changing IP addresses. It uses SSH for initial authentication and to start mosh-server; the interactive terminal then runs over UDP. The Mosh project describes the session as staying alive when a client sleeps and wakes or temporarily loses its internet connection. That describes the protocol’s intended behavior, not a guarantee on every network.

Rank #3
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue | Large AMOLED, High-Res Camera, Durable Design, Super Fast Charging, Expandable Storage, Circle to Search, 2025
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

What Mosh requires

  • The remote host must have mosh-server installed.
  • Your phone’s terminal app must support Mosh.
  • The network and server firewall must allow the selected UDP port. Mosh’s documented default range is UDP 60000–61000; the range can be configured, and firewall rules must match the server setup.

If UDP is blocked on the network you are using, Mosh may not connect. Mosh is for the interactive shell: do not assume it replaces ordinary SSH for port forwarding, proxy-command workflows, or file transfers. Keep SSH available for those tasks.

Keep commands running with tmux

If the main concern is losing work when SSH drops, start the work inside a remote tmux session. On the server, run:

Rank #4
Sale
Samsung Galaxy S26 Ultra, Unlocked Android Smartphone, 512GB, Black | Privacy Display, Galaxy AI, AI Camera, Super Fast Charging 3.0, Durable Battery, 2026, US 1 Year Warranty
  • PRIVACY DISPLAY: Automatically hide your screen from those beside you. The built-in privacy display can be preset¹ to turn on when receiving notifications, typing passwords, or using specific apps
  • TYPE IT IN. TRANSFORM IT FAST: Enhance any shot in seconds on your smartphone by using Photo Assist² with Galaxy AI.³ Add objects, restore details, or apply new styles by simply typing or tapping
  • NIGHTS, CAPTURED CLEARLY: From gigs to city lights, record and capture moments after dark with clarity using Nightography so your photos and videos stay crisp and clear on your Samsung Galaxy
  • MAKE IT. EDIT IT. SHARE IT: Turn everyday moments into something personal with creative tools built right into your mobile phone, whether it’s a special contact photo, custom wallpaper, an invitation or more⁴
  • HELP THAT KEEPS UP: Stay in the moment while Now Nudge with Galaxy AI helps you respond faster and stay organized with smart suggestions⁵ that appear exactly when you need them on your phone
tmux new -s work

Run the command inside that session. After reconnecting, attach to it with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
tmux attach -t work

The OpenBSD tmux(1) manual explains that a tmux session survives accidental disconnection. This protects the remote terminal session and work run inside it; it does not keep the phone’s SSH connection alive or restore input sent while disconnected. If a command was started outside tmux, whether it survives a terminal closure depends on how that command handles hangups and the shell or server environment.

Best Value
Tracfone Moto g Play 2024 Prepaid Phone with a 1-Yr Plan Included | Prepaid Smartphone with Full YR Plan Included bundled with 1500 Min/Text/Data for365 days of service - Locked to Tracfone
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Activating is easy, just 3 steps.
  • ACTIVATION Promotion: Includes 1500 min, 1500 texts & 1500 MB Data + add more as you need it
  • CAMERA SYSTEM: 50MP Quad Pixel camera. Capture sharper, more vibrant photos day or night with 4x the light sensitivity.
  • PERFORMANCE: Blazing-fast Qualcomm performance. Get the speed you need for great entertainment with a Snapdragon 680 processor and 4GB of RAM.
  • 64GB built-in storage. Get plenty of room for photos, movies, songs, and apps. Made for US
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose the fix that matches the failure

Option Addresses Remote setup Survives a network or IP handoff? Keeps remote work alive?
OpenSSH client keepalives Some idle timeouts and detection of an unresponsive path Usually no server change for client-side settings; server-side settings are separate No No, not by themselves
Mosh Interactive terminal roaming and intermittent connectivity Yes: mosh-server and reachable UDP Designed to tolerate it Preserves the interactive remote shell through supported interruptions
tmux Remote terminal and process persistence after a disconnect Yes: tmux must be available on the host No; reconnect separately Yes, for work run inside its session

Use keepalives for a quiet connection that expires while its network path remains intact; Mosh for a roaming interactive shell when UDP and server setup are possible; and tmux when the priority is keeping remote work available to reattach to later. These tools address different failure modes and can be used together.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.