Keep Clash Running in the Background on Android: VpnService Permission & Battery Settings
Fix Clash disconnects when your Android screen locks. Learn how to grant VpnService permission and adjust battery optimization, auto-start, and background settings by device brand.
VpnService permission: Make sure the VPN tunnel is connected
Open your Clash client, select a working profile, then tap “Start” or “Connect.” The first time the client creates a local VPN tunnel through Android’s VpnService, Android usually shows a connection request. Make sure the app name matches the client you just opened, then tap “OK.” This grants the app permission to create a virtual network interface. Importing a subscription, choosing a node, and allowing background activity are separate steps.
After connecting, pull down the status bar or open the system’s “VPN” settings to check whether the client shows as connected. Some devices display a key or VPN icon; others show it only when the status bar is fully expanded. A connected VPN status confirms that the tunnel is up, but it doesn’t tell you whether a domain is going direct or through the proxy. Check the client’s proxy mode, routing rules, and connection logs for that.
- No prompt after tapping Start? Check the system VPN status first. Android usually won’t show the prompt again for an app that’s already authorized. If there’s no prompt and no connection, check the client logs for profile-loading or service-start errors.
- It disconnects as soon as it connects: Check whether another app that uses
VpnServiceis active, such as an ad blocker, firewall, or work VPN. Android typically allows only one active VPN per user or profile. VPN connections in a work profile are managed separately; don’t disable a work VPN required by your organization just to test.
Battery optimization: Exempt only the client you use
If the VPN works with the screen on but disappears after the phone has been locked for a while, check the app’s battery restrictions first. “Whitelist” usually means changing battery usage from “Optimized” or “Restricted” to “Unrestricted,” or selecting “Don’t optimize” under special app access. This can ease some background restrictions, but it won’t prevent a force stop, an app crash, or every manufacturer’s cleanup policies.
- Long-press the client icon on your home screen, then tap “App info.” Look for “Battery,” “App battery usage,” or “Battery management.” Opening settings from the icon helps ensure you’re changing the right client if several apps have similar names.
- On a Pixel running Android 14, go to “Settings” → “Apps” → “See all apps” → your client → “App battery usage,” then select “Unrestricted.” Some newer versions show “Allow background usage” first. Turn it on, tap the row, then choose a battery mode.
- On older Android versions with only “Battery optimization,” search for that term in Settings. Open the list, switch the filter to “All apps,” find your client, and select “Don’t optimize.” On some versions, this option is under “Apps” → “Special app access.”
- Return to the client and confirm it’s connected, then test the lock screen on the same network. Change this setting alone first. If the connection stays stable, there’s no need to enable auto-start or change system-wide battery settings.
When troubleshooting, note whether the system-wide Battery Saver is on. If the connection drops only with Battery Saver enabled, leave the app settings as they are and turn Battery Saver off to run the test again. Once you’ve confirmed the difference, decide whether the client needs fewer restrictions in everyday use.
Background settings in HyperOS, One UI, and other Android skins
Here are common menu paths and search terms for recent versions. Menu names can vary between mainland China and international editions, and may change with system updates. If you can’t find a setting, start from the client’s “App info” page. Change one setting at a time, then repeat the lock-screen test for the same amount of time.
| System | Check first | Check if symptoms persist |
|---|---|---|
| Xiaomi / Redmi · HyperOS | “App info” → “Battery saver” → “No restrictions.” | If the client doesn’t reconnect after a reboot, search Settings for “Background autostart.” If it disconnects only after tapping “Clear all,” check the recent-apps card menu or “App lock” in the Security app. Don’t confuse this with “App lock” for password-protecting apps. |
| Samsung · One UI 6 | Search Settings for “Background usage limits,” then check whether the client is listed under “Sleeping apps” or “Deep sleeping apps.” | If the client keeps getting added to a sleep list, remove it and add it to “Never auto sleeping apps.” Then open the client’s “App info” → “Battery” and check that it isn’t set to “Restricted.” |
| OPPO / OnePlus · ColorOS | Open “App info” → “Battery usage” or “Power usage details” and check whether background activity is allowed. | Search Settings for “Auto launch.” If the connection drops only after clearing recent tasks, look for “Lock” in the recent-apps card menu. |
| vivo / iQOO · OriginOS | Go to “Settings” → “Battery” and look for “Background power consumption management.” Check whether the client is restricted. | To troubleshoot whether the client reconnects after a reboot, search for “Auto launch.” If recent apps has a “Lock” option, test whether it helps by clearing recent tasks once. |
| Huawei · EMUI with Android app support | Search Settings for “App launch,” find the client, turn off “Manage automatically,” and review the manual management options. | If it disconnects when the screen locks, check “Allow background activity” first. If it doesn’t reconnect after a reboot, check “Allow auto-launch.” There’s no need to enable “Allow secondary launch” as well. |
Auto-start, background locking, and Always-on VPN: What’s the difference?
Disconnects after clearing apps? Try locking the app in recent tasks
Swiping an app card away from recent tasks is different from tapping “Force stop” in “App info.” Whether swiping also stops the VPN service depends on the client and the manufacturer’s system. Force stop shuts down the app, and locking its card won’t prevent that. To test the effect of “Clear all,” do only that, then check the VPN status. Don’t also force stop the app from its info page.
Doesn’t reconnect after a reboot? Check whether the client supports it
A manufacturer’s “Auto-start” setting only allows the app to launch in the background; it doesn’t select a profile or start the connection for you. If the client offers options such as “Launch at startup” or “Auto-connect,” enable them as needed. Then reboot your phone and check the VPN status in system settings after unlocking. Opening the client manually first may trigger a connection and make it harder to tell whether startup recovery worked.
Need Android to keep the VPN active? Check “Always-on VPN”
Android 7.0 and later support Always-on VPN. On recent Pixel versions, go to “Settings” → “Network & internet” → “VPN” → the gear icon next to the client. If the option isn’t available, the client may not support it, or device management policies may restrict it. “Block connections without VPN” is a separate setting: when enabled, Android may block network access until the tunnel is ready. If you’re only checking for disconnects when the screen locks, leave it off for now so a temporary loss of connectivity during reconnection isn’t mistaken for a node failure.
Retest with the screen locked: Tell a stopped service from a node issue or network switch
- Record a baseline: Keep the same Wi-Fi network, proxy node, and profile. With the screen on, visit a site that normally loads, then check the connection logs to see which rule and outbound route handled the request. Some sites use a direct connection under your rules, so being able to open one doesn’t prove the proxy is working.
- Lock the screen for 2 minutes, then 15: These are convenient intervals for repeatable tests, not fixed Android cleanup timeouts. Don’t charge the phone during the test. After waking the screen, check the system VPN status before opening the client. Otherwise, the client may reconnect as soon as it opens and hide the disconnection.
- Test Wi-Fi-to-mobile-data switching separately: If the connection stays up while locked in one place but drops when you leave Wi-Fi, keep the other settings unchanged and turn off Wi-Fi manually to reproduce the issue. Check whether the system tunnel is still active and whether the logs show a connection timeout or DNS lookup failure. A network switch can interrupt existing connections without the system stopping the background service.
If the VPN status disappears, check the last client log entry, then investigate battery restrictions, background cleanup, or a service crash. If the VPN is still connected but proxy traffic fails, try a known-working node on the same network. If the logs point to a DNS lookup failure, check the DNS settings. If only one app has problems, check whether it’s excluded by the client’s per-app proxy settings or restricted from using background data by Android. Change one variable at a time to find out what made a difference.