On this page
What happens to a VPN during sleep
A VPN is a few connections that have to stay alive: the tunnel to the server and, inside it, each app's own connections. During sleep the computer sends nothing, the Wi-Fi adapter usually powers down, and the other side waits only so long. On waking, Wi-Fi reconnects, the router may hand out a new address, and if you opened the lid somewhere else, it's another network altogether. The client often doesn't notice: it was frozen along with everything else, so it shows Connected while nothing goes through.
Why the tunnel doesn't come back
- The network went away and came back — maybe with a new IP. A client tied to the old address or interface keeps sending into nothing.
- The route to the server points at the old router — a VPN client sends traffic for the server's address through your router. Wake up on another network, and that route leads nowhere until the client rebuilds it.
- The connections inside are dead — the server closed idle connections while you slept. Protocols over TCP (VLESS, Trojan, VMess, Shadowsocks) need new ones, and apps that kept an old one hang until it times out.
- The router forgot the UDP mapping — routers and carriers keep UDP mappings only briefly. WireGuard, AmneziaWG and Hysteria2 make a new one with the first packet after waking.
- The clock jumped — if it is set back after waking, a WireGuard server ignores handshakes stamped earlier than the last one it accepted, and VMess fails with a clock more than 90 seconds off.
- The name was resolved before sleep — WireGuard looks up an Endpoint given by name once, when the tunnel starts. If the server's address changed meanwhile, it keeps knocking on the old one.
- The system held the app back — on laptops with Modern Standby, Windows keeps the network on or off in sleep depending on the model; Android's Doze and brand battery savers can suspend or stop a VPN app.
- A sign-in page — hotel and café Wi-Fi often wants its terms accepted again after waking, and a kill switch can block that page too: disconnect for a moment, sign in, connect again.
What you see, why, and what to do
Connected after waking, but nothing loads
CauseThe tunnel's connections died in sleep, and the client hasn't noticed
What to doReconnect; turn on the client's check that traffic flows
New sites open, but a chat, a download or a call hangs
CauseThose apps kept connections that died during sleep
What to doWait a minute or restart that app: the VPN itself is fine
It works after waking at home, not somewhere else
CauseThe route to the server still goes through the old router
What to doReconnect after joining the new network
The VPN keeps reconnecting, Wi-Fi is up
CauseThe network wants you to sign in, or doesn't let this protocol through
What to doAccept the network's sign-in page; if there is none, try another protocol
WireGuard:
wg showhas no fresh handshake after wakingCauseThe Endpoint name points at an old address, or the clock went back
What to doRestart the tunnel; check the time
Wi-Fi itself comes back slowly, or not at all
CauseThe adapter's power saving
What to doTurn off power saving for the network adapter
The phone's VPN is off after it lay unused
CauseDoze or a battery saver stopped the app
What to doRemove battery limits for the VPN app, turn on Always-on VPN
What helps
- 1
Reconnect
Turn the VPN off and on. It does everything at once: a new route, new connections, a fresh handshake.
- 2
Let the client watch the tunnel
Many clients can reconnect after a drop or a network change; turn that on. The most useful kind checks that traffic actually flows, because after sleep the tunnel exists and carries nothing.
- 3
Add keepalive to WireGuard
PersistentKeepalive = 25in[Peer]sends a tiny packet every 25 seconds while the tunnel is idle. Nothing goes out during sleep itself, but it keeps the router's mapping open while the machine sits idle and helps the handshake come back right after waking. - 4
Turn off the adapter's power saving
On Windows: Device Manager → Network adapters → your Wi-Fi adapter → Properties → Power Management, untick “Allow the computer to turn off this device to save power”. Some laptops don't have this tab.
- 5
On a phone, remove the battery limits
Settings → Apps → the VPN app → Battery: Unrestricted (names differ between brands). Then Settings → Network & internet → VPN → the gear next to the app → Always-on VPN: the system starts the VPN by itself and keeps it running.
Find out what happened
Match the time the machine woke up with the moment the VPN failed.
Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Microsoft-Windows-Power-Troubleshooter'} -MaxEvents 5 | Format-List TimeCreated, MessageEach entry is one wake: the sleep time, the wake time and what woke the machine.
powercfg /aStandby (S0 Low Power Idle) Network Connected — the laptop keeps Wi-Fi on in sleep. Network Disconnected — it turns Wi-Fi off, so even a short sleep takes the tunnel's connection down.
Restart-Service 'WireGuardTunnel$wg0'Restarts the tunnel named wg0 in the official WireGuard app; put your tunnel's name after the $.
pmset -g log | grep -E "Sleep|Wake" | tail -n 20The latest sleeps and wakes, with times and reasons.
sudo journalctl -b -k | grep -E "PM: suspend (entry|exit)"
sudo wg showEach suspend entry and suspend exit pair is one sleep since boot. After waking, latest handshake in wg show should be seconds old again; if it stays minutes old, sudo wg-quick down wg0 && sudo wg-quick up wg0.
Which protocols take sleep better
WireGuard and AmneziaWG have no connection to lose: after waking they do a fresh handshake with the next packet and carry on, even from a new address, since the server learns where the client is from its signed packets. When they don't recover, the cause is usually the route, the Endpoint name or the clock. Protocols over TCP, such as VLESS, Trojan, VMess and Shadowsocks, keep connections open to the server, and those don't survive a long sleep: new ones usually work at once, the old ones hang, and the client has to notice.