Home / VPN guides / WireGuard PersistentKeepalive: When 25 Seconds Helps
WireGuard PersistentKeepalive: When 25 Seconds Helps
Quick answer: WireGuard’s PersistentKeepalive sends small, authenticated empty packets at a chosen interval so a NAT device or stateful firewall is less likely to forget an idle peer’s mapping. It is off by default. WireGuard’s documentation gives 25 seconds as a useful example for many NAT scenarios, not a setting everyone should enable. It does not repair incorrect keys, blocked UDP traffic, DNS failures, MTU problems or a missing route.
Reviewed 6 November 2026. SealedVPN is an independent educational publisher, not a VPN operator. This explanation is based on cited documentation, not on a hands-on performance test.
Jump to a section
What PersistentKeepalive actually does
WireGuard usually sends packets only when it has traffic to transmit. That quiet behavior is intentional. But a peer behind a network address translation (NAT) device might receive a reply only while the NAT device remembers the recent outbound flow. If the peer stays quiet long enough, the mapping can expire. A periodic authenticated empty packet can keep the mapping active so traffic can return to that peer.
This is a network reachability mechanism, not a second encryption mode, special VPN security guarantee or a way to improve the privacy of your browsing. The official WireGuard Quick Start explains the NAT/firewall case and the optional persistent interval. The WireGuard tools manual documents the configurable field.
Three scenarios: when it helps and when it may not
| Scenario | Likely decision | Reason |
|---|---|---|
| A phone or remote laptop sits behind NAT and must receive traffic after long idle periods. | Consider a keepalive on that NAT-side peer. | Periodic outbound packets may preserve the NAT mapping for return traffic. |
| A publicly reachable server normally receives client-initiated connections. | Usually leave the server peer’s persistent interval off unless its network design requires it. | The client can establish the outward mapping; both sides do not automatically need keepalives. |
| A tunnel is actively carrying traffic and works normally. | Keep the default unless idle-time failures actually occur. | Ordinary traffic already refreshes many NAT mappings; unnecessary keepalives add traffic. |
The deciding question is not simply “client or server?” It is which peer sits behind NAT or a stateful firewall, who must initiate traffic after idling, and whether a stable mapping is needed. Enterprise networks and carrier-grade NAT can behave differently, so an example configuration is not a guarantee.
What does PersistentKeepalive = 25 mean?
Inside a WireGuard peer configuration, the following line specifies an interval in seconds:
[Peer] # Other peer settings belong here PersistentKeepalive = 25
WireGuard documents 25 seconds as a sensible example across many firewalls. It is not a universal optimum and not the protocol’s default. Leaving the field out, or setting it to 0, disables persistent keepalives. The official wg(8) manual describes a supported nonzero interval of 1–65535 seconds.
For managed consumer VPN apps, the field may not be user-configurable. Do not edit a provider-managed configuration just to reproduce this example. Some service providers distribute profiles or apply their own connection-management logic.
A reversible diagnostic sequence
- Record the symptom first. Does the tunnel work immediately after connecting, then stop receiving traffic after ten or twenty minutes of idling? Compare the same action before and after an idle period rather than assuming every disconnection is NAT timeout.
- Check whether the handshake ever succeeds. On a Linux machine where you administer WireGuard, sudo wg show can display peer handshake timestamps and transfer counters. Avoid sharing private keys, endpoint addresses or complete configuration files in public troubleshooting posts.
- Verify the rest of the connection. If no handshake can be established at all, begin with the WireGuard handshake troubleshooting guide before changing keepalive behavior.
- Decide which peer needs it. A peer sitting behind NAT and expected to receive traffic after it has become idle is the usual candidate. Change settings only if you control that configuration or have approval from its administrator.
- Make one change and observe. Record the previous interval. If you can safely edit the peer setting, test an interval supported by your network or service documentation, and then repeat the idle-time scenario. Revert if it does not improve the symptom or changes battery/network behavior.
- Review counter-evidence. Handshake time, packet counters, route selection and application symptoms should tell a consistent story. A temporary improvement after reconnecting does not prove that keepalive was the cause.
WireGuard’s command and configuration conventions vary between interfaces and device platforms. If you use wg-quick or a managed network service, follow that system’s documented save and reload method, not an unreviewed command copied from the web.
What this setting does not fix
| Symptom | More useful next check |
|---|---|
| No successful handshake ever appears | Endpoint reachability, keys, clocks and UDP/firewall configuration: handshake guide. |
| Handshake works, but some websites hang or large downloads fail | MTU and path behavior: WireGuard MTU guide. |
| Connection works, but only certain destinations fail | Routing and AllowedIPs: full versus split tunnel guide. |
| Wi-Fi-to-cellular switching disrupts the connection | Network switching, app behavior and reconnect policies: VPN disconnecting guide. |
Practical trade-offs and limitations
Every enabled interval adds periodic traffic. For frequently idle mobile devices, that may have some network and power impact, although the amount depends on the operating system, radio state and implementation; we have not measured it. A firewall or mobile carrier can still interrupt a connection. Keepalive traffic does not grant access through a firewall that actively blocks the tunnel.
A commercial VPN subscription also may not provide direct inbound connectivity to your home device, even when it uses WireGuard. That depends on the provider’s network design; a keepalive interval is not a substitute for access to the intended remote peer.
Questions readers ask
Should I set 25 on both sides?
Not automatically. Start by identifying which peer has the NAT mapping that must remain available. Both peers sending unnecessary keepalives can create traffic without solving the real issue.
Does it keep my phone VPN permanently connected?
No. It can help preserve a mapping during idle periods, but does not guarantee continuous connectivity after a device sleeps, changes networks, loses signal or encounters VPN-app limitations.
Is 0 a broken configuration?
No. Zero disables the feature, matching WireGuard’s normal default. Enable it only for an identified network requirement.
Primary references and further reading
WireGuard — Quick Start, NAT and Firewall Traversal Persistence; WireGuard tools — wg(8) source manual; Ubuntu Server — common WireGuard administration tasks. For protocol-level context, see our WireGuard vs OpenVPN comparison.
Editorial note: This guide was prepared with AI-assisted drafting and fact-checked against the linked primary technical sources. SealedVPN has not performed independent device testing for this article and has no provider placement or affiliate arrangement in it.
General information based on the sources linked above. Settings, prices and terms change, so confirm them with your provider or device maker. Found an error? Tell us.