This is not the “every node times out” problem
If latency tests are red for every outbound right after you paste a subscription URL, you are in a different failure mode—DNS modes, captive portals, per-app scope, or upstream blocking. Our seven-step Android connectivity checklist covers that stack in order. Keep this page open when the symptom is instead: everything works while the app is foregrounded, then Android idling kills the process or suspends the VPN service minutes later.
Separating the two saves time. Power-policy fixes will not heal a broken resolver, and DNS tweaks will not stop Xiaomi or Oppo memory cleaners from swiping your tunnel off the recents deck. Once you know you are in the background-kill bucket, the checklist below is the fastest route to stability without rooting the phone.
Why OEM Android builds love to kill Clash-class clients
From the operating system’s point of view, a Clash for Android fork is a persistent VPN with periodic wakeups, optional notification updates, and sometimes a foreground service that holds a tun interface. That profile trips every heuristic meant to stop misbehaving chat apps from burning battery overnight. Battery optimization (App Standby buckets), adaptive battery, and vendor “AI” cleaners all assume that freezing background work is a feature, not a bug.
The result is predictable: the tunnel comes up, you lock the phone, Doze tightens job scheduling, and the OEM adds another layer—autostart denied, secondary launch off, or “clear open apps” wiping your recents row. None of that contradicts a valid subscription URL; it simply means Android never gave your process a fair chance to stay resident. The fix is administrative: tell the OS this app is allowed to run, then give the recents stack a visual “do not evict” hint where the vendor exposes it.
Forks matter too. Package names differ between Meta-compatible builds and older community editions. Always apply allowances to the exact icon you launch, not a stale clone left over from an experiment. Dual-app and work-profile installs multiply this confusion—permissions are per-user, and a VPN running in the primary profile will not magically proxy a browser that only exists in the work profile.
Step 1: Prove the VPN dies from policy, not from crashes
Before you touch sliders, reproduce the failure once with intent. Start the client, confirm the system VPN key appears, then leave the phone on a desk for five to fifteen minutes with the screen off. If the key disappears at the same time apps lose connectivity, you are dealing with lifecycle teardown—not intermittent packet loss.
Open the client’s log or status page immediately after the drop (if your build exposes it). Crash signatures look like abrupt process death with stack traces; policy kills often look like a clean service stop paired with a notification that “VPN disconnected” without an in-app exception. Either way, disable any second VPN or Private DNS experiment while testing—two tunnel contenders fighting for the same slot can masquerade as a power issue.
If you recently changed profiles, confirm the YAML still parses: a delayed crash when the core reloads rules can feel like a background kill. Swap to a minimal profile for ten minutes; if stability returns, merge complexity later. When the minimal profile still dies on schedule, continue—your next hour is about battery optimization and OEM menus, not about rewriting rules.
Step 2: Remove battery optimization and allow unrestricted usage
Open Settings → Apps → [Your Clash app] → Battery (wording varies). Switch from “Optimized” to Unrestricted or equivalent. On Google-flavored builds this single toggle often suffices; on MIUI / HyperOS you may also need Other permissions → Start in background and a separate “No restrictions” entry under Power saver.
While you are in the app info screen, confirm Mobile data & Wi‑Fi allows background data. Some carriers ship “data saver” defaults that block unmetered sync for VPN helpers until you explicitly permit them. Flip Wi‑Fi off and on once after changes; a few ROMs only re-evaluate firewall rules on interface bounce.
Disable any third-party “battery doctor” or antivirus that claims to hibernate apps. Those tools reintroduce the same freezes you just removed at the OS level. If you must keep one, whitelist your Clash package there as well—not only in the stock settings app.
When two builds are installed side by side after a rename, Android may still optimize the old package ID until you clear its entry under Battery → App usage lists. Uninstall abandoned forks so the OS is not thrashing a dead UID while your active icon starves. Document the exact version string you run—screenshots of the battery page help when a forum asks whether you granted “unrestricted” to the correct binary.
Step 3: Enable autostart and secondary launch (where OEMs hide them)
Autostart is the permission that lets the app resurrect its service after a reboot or after the system clears memory. On Xiaomi / HyperOS, open Security → Autostart (or Permissions → Autostart on newer builds) and enable your client. Pair it with Display pop-up windows while running in the background if the wizard prompts—some builds refuse to raise the VPN consent dialog unless that capability is allowed.
ColorOS / OxygenOS on OPPO and OnePlus devices often place the same idea under App management → Autostart plus an “allow activity” toggle. vivo labels it High background power consumption; realme mirrors ColorOS. Samsung One UI rarely uses the word autostart, but Settings → Apps → Special access → Optimize battery usage must list your app as Not optimized, and Never sleeping apps under Device care catches stragglers.
If your fork offers a “start on boot” switch inside the app, turn it on after system autostart is granted—otherwise the internal flag fires before the OS permission exists, and you get a silent failure until the next manual launch.
Step 4: Lock the task in recents and exclude it from “boost” cleaners
Open the recent apps overview, locate your Clash card, and use the vendor-specific lock icon—often a padlock or downward chevron menu. On MIUI, pulling the card downward pins it; on ColorOS, the lock sits in the corner overlay. This step does not replace battery optimization settings, but it prevents one-tap RAM cleaners from discarding your session when you “clear all” out of habit.
Teach yourself to avoid global “boost” buttons that ship in launcher folders or security centers. Those utilities exist to reclaim memory for marketing screenshots, not to preserve long-lived VPN state. If you must run them, lock the task first, or expect to tap Start again afterward.
On tablets or foldables, verify both display modes: some OEMs reset recents locks when you unfold the device or switch freeform windows. Re-lock after form-factor changes until you know your ROM’s quirks.
Step 5: Notifications, foreground service, and post-reboot verification
Android 13+ makes notification channels meaningful. Ensure the client’s VPN / running channel is allowed—not set to silent suppression—so a foreground service can legally post the persistent status the OS expects. If you aggressively disabled “ongoing” notifications for the app, some builds downgrade the service priority and kill it sooner under memory pressure.
Return to the app, start the tunnel, then reboot the phone. Before unlocking unrelated apps, confirm whether the VPN reconnects automatically. If not, open the client once manually, accept any refreshed consent dialog, and repeat Step 3: autostart is frequently the missing piece after firmware updates wipe permission matrices.
Finally, run a boring idle test: screen off, audio streaming or a gentle ping in the background, fifteen minutes. Success means the key icon stays and egress still routes through your node; failure means you missed a vendor-specific submenu—scroll to the OEM cheat sheet below before assuming the binary is corrupt.
OEM cheat sheet: where the traps live in 2026
MIUI / HyperOS (Xiaomi, Redmi, POCO): Stack Autostart, Battery saver → App battery saver → No restrictions, and the recents lock. Watch for MIUI Optimization under developer options—turning it off changes scheduler behavior and can confuse support, so prefer official toggles first. If the Security app pushes “Battery & performance” suggestions, dismiss them for your VPN package.
ColorOS / realme UI (OPPO, OnePlus, realme): Besides autostart, inspect App battery management for “Allow background activity.” Some builds split Wi‑Fi and cellular background permissions—set both to allowed during testing.
One UI (Samsung): Combine Unrestricted battery with Never sleeping apps and verify Put unused apps to sleep is not silently re-adding your client after updates.
HarmonyOS / EMUI (Huawei): Launch settings often include Manage manually with checkboxes for secondary launch and run in background—enable all that your org policy permits.
Stock Pixel and near-AOSP ROMs usually need only unrestricted battery plus a stable foreground notification, but Digital Wellbeing bedtime modes and focus schedules can still pause alerts; exclude the VPN channel from those routines if you rely on overnight connectivity.
What this cannot fix
No amount of lock task wizardry survives honest out-of-memory kills when the device has 3–4 GB RAM and twenty games in recents. Close heavy apps or accept occasional teardown. Likewise, carrier-grade NAT timeouts and captive portals on hotel Wi‑Fi will drop tunnels even when the OS is friendly—complete the portal login before starting Clash.
If you need enterprise compliance, MDM profiles can forbid persistent VPN or mandate always-on corporate clients that preclude a second tunnel. Those constraints are policy, not battery math—talk to IT instead of chasing autostart toggles.
For protocol and rules depth after the tunnel stays up, the YAML routing guide remains the best next read; it explains how policy groups interact with DNS so your mobile profile does not fight the desktop YAML you pasted.
Quick FAQ
Why does Clash for Android disconnect after I lock the screen? Android and OEM skins freeze VPN-style apps to save battery. Without unrestricted power, autostart, and often a locked recent task, the system suspends your process or tears down the tun interface.
Does locking Clash in recents really help on MIUI or ColorOS? Yes—the padlock tells memory cleaners to skip that task during boosts. Pair it with unrestricted battery; neither alone is reliable on aggressive ROMs.
Is this the same fix as when every node shows timeout after subscription import? No. Mass timeout is usually DNS or network path—use the dedicated article. Here we assume imports work until idle policies strike.
Will disabling battery optimization drain my phone faster? The tunnel itself dominates cost; unrestricted power mostly stops freeze/reconnect thrash. For long trips, schedule off-hours instead of letting the OS flap the service.
Open source, forks, and support channels
“Clash for Android” may refer to multiple maintained forks with different defaults. For engine bugs, upstream trackers are appropriate; attach your core build string and ROM version. The Clash Meta for Android repository is a common reference for Meta-compatible sources—use it for issues and transparency, while grabbing installable builds from a trusted distributor such as our download page so you are not hunting APKs at random mirrors.
Closing thoughts
Mobile proxies fail in layers. Compared with opaque one-tap VPNs that hide every knob, Clash for Android rewards users who spend ten minutes in OEM settings: unrestricted battery optimization, honest autostart, a lock task pin, and a visible notification channel buy you the same stability enthusiasts expect on desktops—without pretending Chinese ROMs behave like Pixels.
Once the tunnel survives lock screen and idle, return to refining your subscription URL rotation and rules. Compared with chasing phantom server outages, taming the power menu is boring work that pays off every day you forget the app is even running.
For Android TV sideload workflows, continue with the Android TV guide; for more networking topics, browse the full tech column.