VPN disconnects when the screen turns off
A VPN that drops when the screen turns off is usually stopped by Android's battery optimisation or a manufacturer task killer; exempt it and use Always-on.
A VPN that drops every time the screen turns off is almost always being stopped by the phone, not by the network or the server. Android's battery optimisation, or a manufacturer's own background task killer on top of it, decides the VPN app has been idle and ends the service that holds the tunnel open. The fix is to exempt the app from battery optimisation, disable any manufacturer restriction on it, and turn on Always-on VPN so the system restarts it if it is stopped anyway.
Why the screen is the trigger
Screen-off is the signal Android uses to start winding the phone down. After a period still and unplugged, the phone enters deep sleep, network access for apps is batched, and any app the system considers idle can have its background work stopped. A VPN is a background service by nature, so it is exactly the kind of thing the system is looking at.
On a plain Android build the rules are documented and a VPN's foreground service usually survives them. Many manufacturers add a second layer, with its own list of apps allowed to run in the background and its own idea of what counts as idle, and those are where most disconnects come from. The app is not crashing; it is being told to stop.
Telling which one it is
| What you see | Likely cause |
|---|---|
| The VPN notification disappears while the screen is off | The app's service was stopped by the system or a task killer |
| The notification stays but the tunnel is down on unlock | Wi-Fi was turned off during sleep, or the network changed |
| It reconnects itself within seconds of unlocking | The app was stopped and restarted; battery optimisation |
| It stays disconnected until you tap connect | A manufacturer task killer that also blocks auto-restart |
| It drops on mobile data but not on Wi-Fi | The carrier's connection tracking expired; see keepalives below |
Fix 1: exempt the app from battery optimisation
- Open Settings and search for "battery optimisation", or open Apps, then the VPN app, then Battery.
- Set the app to Unrestricted, or choose "Don't optimise" from the list of apps.
- On the same screen, if there is an "allow background activity" switch, turn it on.
This tells Android not to treat the app as idle, and on plain Android it is usually enough. The battery optimisation post has the full set of screens.
Fix 2: the manufacturer's own killer
Samsung, Xiaomi, Huawei, Oppo, OnePlus and others each add their own background manager with a different name: sleeping apps, deep sleeping apps, autostart, app launch management, battery saver with per-app rules. They run alongside the Android setting and override it. The VPN app needs to be allowed in each one: removed from any sleeping list, allowed to autostart, and set to "no restrictions" where there is a per-app battery mode. The steps for the common brands are in keeping a VPN alive on Samsung and Xiaomi phones.
Fix 3: Always-on VPN
Android can be told that a VPN app should always be running. Under Settings, Network, VPN, tap the gear next to the app and turn on Always-on VPN. If the service is stopped for any reason, the system restarts it, and if you also turn on "Block connections without VPN", nothing leaves the phone in the seconds before it comes back. This does not prevent the app being stopped, but it removes the cost. What the setting does and does not do is in Always-on VPN on Android.
Fix 4: Wi-Fi during sleep
Some phones turn Wi-Fi off after the screen has been off for a while, especially on battery. When the screen comes back, Wi-Fi returns and the VPN has to reconnect; if it reconnected on mobile data in between, you see a drop and a reconnect. Look for a "keep Wi-Fi on during sleep" or "Wi-Fi in sleep mode" setting under Wi-Fi's advanced options, and set it to always.
Mobile data and the quiet tunnel
On mobile data there is one cause that is not the phone. Carriers sit phones behind shared address translation, and a connection that sends nothing for a few minutes is forgotten by the carrier's equipment. When the phone next sends a packet through the tunnel, the server's replies no longer have a path back. Well-designed VPN protocols send a small keepalive every so often to stop that happening, and a good app tunes the interval for mobile networks; the keepalive post explains the mechanism. If drops only happen on mobile data with the screen off, this is the cause, and the fix is in the app rather than in Settings.
What it is not
The server does not know or care whether your screen is on. A screen-off disconnect that looks like a server problem, because the app briefly shows an error when it comes back, is still a decision the phone made. And it is not a leak, provided the tunnel is either up or the phone is blocking traffic outside it; that is what Always-on with blocking is for.
Culvert VPN runs as a foreground service with its own notification, reconnects automatically after the system stops it, and works with Android's Always-on and block-without-VPN settings, whose real state its Settings screen reports; it is on Google Play.
Questions people also ask
Why does it only happen after a few minutes, not straight away?
Android waits until the phone has been still and unplugged for a while before entering deep sleep, and manufacturer battery managers use their own timers. The delay is the system deciding the app has been idle long enough to stop.
Will Always-on VPN stop the disconnects?
It stops the consequences. Android restarts an always-on VPN whenever it is not running, and with "Block connections without VPN" nothing leaves the phone in the gap. Exempting the app from battery optimisation stops it being killed in the first place.
Does the VPN server know my screen is off?
No. The server only sees packets stop arriving, and it treats that the same as a phone that walked out of range. Screen-off disconnects are decided entirely on the phone.