· Platform Guides · 8 min read

Clash for Android: VPN permission, battery optimization exemptions, and background settings

Set up Android VPN permissions, battery optimization exemptions, and auto-start to help prevent Clash from disconnecting in the background.

First connection: Allow Android's VPN request

VpnService is Android's VPN interface. Clash clients that support VPN mode use it to create a local virtual network interface and receive traffic routed to it by the system based on routing rules and app selection. The Clash or mihomo core then decides whether to connect directly or use a proxy, according to the active configuration. When Android shows that the VPN is connected, it means the interface is up—not that every request is being proxied or that the selected node is reachable.

  1. Select a configuration first. Import a working configuration from the client's Configuration or Subscriptions page. Once it's imported, select it and return to the home screen to confirm it's active. Adding a subscription to the list alone won't start a connection.
  2. Then start the VPN. Tap Start or the connect button on the home screen. If the client offers both proxy-only and VPN modes, choose VPN mode. When Android displays a connection request, check the app name in the prompt and tap OK or Allow.
  3. Check the system status. On a Pixel, for example, go to Settings → Network & internet → VPN and check whether the client is connected. The key icon may not remain visible on every Android version, so use the VPN settings page as the source of truth.
  4. Send a fresh request. Refresh a page in your browser, then check the client's Connections or Logs. If the request isn't listed, first check whether the browser is on the app bypass list. If it appears but the page won't load, check the matched rule, outbound group, and error details.

Battery optimization exemptions: Adjust settings for individual apps

If Clash works with the screen on but disconnects after the screen locks, start by changing the client's battery settings. There's no need to disable battery saver for the entire phone. Depending on the device, the exemption may be called Unrestricted, Allow background activity, or Never sleeping. Common settings paths are listed below, but menus vary by model, region, and OS version. If you can't find the option, long-press the app icon and open App info, or search Settings for the terms in the table.

DeviceCommon settings pathWhat to change
Pixel(Android 14)Settings → Apps → select the client → App battery usageAllow background usage. If Unrestricted is available, try that and test again.
Xiaomi / Redmi (HyperOS)Settings → Apps → App management → select the client → Battery saverChoose No restrictions. To test automatic relaunch, search for Background autostart.
Samsung (One UI)Settings → Battery → Background usage limits; on some versions, go to Battery through Device careRemove the client from Sleeping apps and Deep sleeping apps. You can also add it to Never auto sleeping apps.
Huawei (EMUI with Android app support)Settings → Apps → App launchTurn off automatic management for the client, then allow Background activity under manual management. Enable Auto-launch only if needed.
OPPO / OnePlus (ColorOS)From App info, open Power usage or Battery usageAllow background activity. If the client supports connecting on boot but doesn't reconnect, check the Auto-launch setting too.
vivo / iQOO(OriginOS)Settings → Battery → Background power consumption managementAllow the client to run in the background. If you can't find the setting, search for Background power consumption management.

Troubleshoot lock-screen disconnects and startup separately

Background battery settings control whether an app that's already running can keep running. Auto-start settings only loosen restrictions on when it can launch. If the VPN disconnects only after the screen locks, test the battery settings first. If it fails only after a reboot, check whether the client supports Start on boot or Auto-connect. Enabling the manufacturer's auto-start option won't establish a VPN for a client that doesn't support automatic connection. After rebooting, unlock the phone once, then check the status on the system VPN page.

Some phones let you lock an app in the recent apps screen. This mainly prevents Clear all from closing the client; it doesn't replace background settings. To test for lock-screen disconnects, press Home to return to the home screen. Don't swipe the app away or tap Force stop in App info.

Missing notifications: Check whether they're hidden or the service has stopped

Starting with Android 13 (API 33), apps that target the relevant Android version need notification permission to show regular notifications. If permission is denied, a foreground service may still be running, with its notification shown under Active apps in Android settings instead of the notification shade. Conversely, a connection notification from the client doesn't prove that the current node is reachable.

  • The system VPN is connected and webpages load: Long-press the client icon and go to App info → Notifications, then turn on Allow notifications. If notification categories are listed, check options such as Connection status or Service. If notifications are missing only from the lock screen, also check the system's lock-screen notification settings.
  • The notification is gone and the system VPN isn't connected: Reopen the client and start it manually, then repeat the test using the same screen-lock duration. If it disconnects after running in the background for a while, check the sleep lists and background battery settings first—not notification permissions.
  • The VPN still shows as connected, but webpages won't load: Check the client logs for new requests. If you see DNS lookup failures or connection timeouts, note the errors and compare with another working node or network. Don't assume these errors mean the system closed the app in the background.

Retest after locking the screen or switching networks—change one setting at a time

Use the same browser, configuration, and node for each comparison. For every test, note the phone model, OS version, client version, and when the disconnect occurs. The 5- and 15-minute intervals below are troubleshooting durations, not fixed system timeout thresholds. If the VPN usually disconnects after 30 minutes, repeat the final test for that long.

  1. Note the starting state. Connect to Wi-Fi, start the VPN manually, confirm it's connected on the system VPN page, and load a webpage in your browser. Note the time of the request in the client logs.
  2. Test the lock screen only. Return to the home screen and lock the phone for 5 minutes. After unlocking, check the system VPN status before opening the client. Refresh the browser, then check the logs for a new request at the same time. If it works after 5 minutes, repeat the test for 15 minutes.
  3. Change only the battery setting. If the same screen-lock test reproduces the disconnect, relax the background restriction for this client only. Leave notification and auto-start settings unchanged. Repeat the test for the same duration to confirm whether the change helped.
  4. Test network switching separately. Reconnect, keep the screen on, turn off Wi-Fi, and wait for 4G or 5G to appear in the status bar. Then reload the same page. If it fails only after switching networks while the VPN still shows as connected, reconnect manually once to see whether that fixes it. Then check for node connection or DNS errors. This is different from the service stopping after the screen locks.

Keep only the settings that fixed the problem. If the issue persists, note one or two log entries from before and after the disconnect, along with the system VPN status, whether the screen was locked, and the network in use. Continue troubleshooting by symptom on the troubleshooting page. Before sharing screenshots, hide subscription URLs, tokens, and account details.

Download Clash