WireGuard slow speeds: find the real cause
Slow WireGuard is usually an MTU problem. Find your path MTU by bisection, clamp TCP MSS, check steal time, and measure the path before blaming the tunnel.
Where WireGuard slow speeds actually come from
WireGuard slow speeds trace back to one of four things, and those four are not equally likely. First is MTU (maximum transmission unit): the tunnel builds packets that are too large for one link on the path, so bulk transfers stall while small ones look healthy. Second is the path itself, which was already the limit before the tunnel existed. Third is CPU on a small shared VPS, where encryption competes with every other guest on the same host. Fourth is the peer's own connection.
Check them in that order. MTU comes first because it is the only cause on the list that WireGuard itself introduces, and because its symptoms do not look like slowness at all. A wrong MTU usually shows up as a tunnel that connects instantly, answers ping, accepts an SSH login, and then freezes the first time you copy a file.
One symptom is worth ruling out before any of this. If every new site takes several seconds to begin loading and then transfers at full speed, that is name resolution rather than throughput. DNS over WireGuard has its own failure modes, and no MTU change fixes them.
Why is the WireGuard MTU 1420?
Every packet you send into the tunnel is encrypted and wrapped inside a new packet. The wrapper costs bytes, and those bytes come out of your payload.
The WireGuard data overhead is 32 bytes: a 1 byte type field, three reserved zero bytes, a 4 byte receiver index, an 8 byte counter, and the 16 byte Poly1305 authentication tag. Around that sits a UDP header of 8 bytes. Around that sits the outer IP header, which is 20 bytes for IPv4 and 40 bytes for IPv6. Total encapsulation is therefore 60 bytes when your Endpoint is an IPv4 address and 80 bytes when it is IPv6. The WireGuard protocol page documents the message layout these numbers come from.
wg-quick does not guess at this. On Linux, it uses the smallest route or interface MTU found for its endpoints, falls back to the default route when needed, and then subtracts 80. On an ordinary 1500 byte Ethernet path that produces 1420, which is the value ip link show wg0 prints. It subtracts 80 rather than 60 so the same figure stays safe if that endpoint is ever reached over IPv6, where the outer header is 20 bytes larger.
The data behind this chart
[
{
"label": "Ethernet, IPv4 endpoint",
"path_mtu": 1500,
"encap_overhead": 60,
"usable_wg0_mtu": 1440
},
{
"label": "Ethernet, IPv6 endpoint",
"path_mtu": 1500,
"encap_overhead": 80,
"usable_wg0_mtu": 1420
},
{
"label": "PPPoE DSL, IPv4 endpoint",
"path_mtu": 1492,
"encap_overhead": 60,
"usable_wg0_mtu": 1432
},
{
"label": "Extra tunnel in the path",
"path_mtu": 1400,
"encap_overhead": 80,
"usable_wg0_mtu": 1320
}
]Those 4 rows are arithmetic, not measurements. On a clean 1500 byte path with an IPv4 endpoint, 1440 would fit, so the default of 1420 leaves 20 bytes unused. That margin is intentional and it is not your problem.
The last row is the one that hurts. When some link on the path carries only 1400 bytes, a tunnel still set to 1420 produces a 1480 byte outer packet on every full size segment when the endpoint is an IPv4 address, which is 80 bytes more than that link will accept. With an IPv6 endpoint the outer packet is 1500 bytes and the overshoot is 100. The value that fits either way is 1320.
Do not copy 1320 either. Your path MTU is a property of your path, and the only way to know it is to measure it.
What a wrong MTU looks like
The failure is not gradual. It is a clean split between small packets and large ones.
pingacross the tunnel works at any normal size.- An SSH login completes and typing feels responsive.
curl -I https://example.comreturns headers immediately.curl https://example.comon a large page hangs after the first few kilobytes.scpof a big file starts and then stops at some percentage.- An SSH session freezes the moment you run a command that prints a lot of output.
All of this happens because a TCP connection only builds full size segments once it has bulk data to move. The handshake and the first request fit under every MTU on the path. The stall begins at the first full size segment, which is why the connection looks healthy right up to the point where it becomes useless.
An outer packet larger than the next link's MTU meets one of two fates.
It is fragmented. An IPv4 router splits it if the DF bit is clear, and the far end reassembles the pieces; IPv6 routers never fragment packets. The transfer works and it is slower, because you now pay two packets for one and the receiver holds state until both arrive. Losing one fragment loses the whole original packet, so a path with 1% loss behaves like a much worse path. Many firewalls also drop IP fragments by policy, which turns this outcome into the next one.
It is dropped, and you may or may not be told. An IPv4 router that cannot forward a packet with DF set sends an ICMP (internet control message protocol) "fragmentation needed" message back to the sender, carrying the MTU it can accept; an IPv6 router sends ICMPv6 "Packet Too Big". If that message arrives, path MTU discovery works and the sender lowers its segment size on its own. Many networks filter ICMP, so it often does not arrive. Nothing else reports the loss. That is the black hole: the packet leaves, nothing comes back, no error appears in any log at either end, and the transfer hangs until something times out.
How do I find the right MTU?
Measure the path, then do the subtraction. Test the underlay rather than the tunnel, so ping the server's public address from the client and forbid fragmentation.
ping -M do -s 1472 -c 3 203.0.113.10-M do sets the DF (don't fragment) bit, so no router on the way is allowed to split the packet. -s is the ICMP payload size. A full IPv4 packet is that payload plus 8 bytes of ICMP header plus 20 bytes of IP header, so -s 1472 puts exactly 1500 bytes on the wire.
Three results matter. Clean replies mean 1500 bytes fits on the path your pings took, so MTU is probably not your problem. Tunnel traffic is UDP rather than ICMP, though, and a router that balances load across several paths can send it a different way, so a transfer that still hangs keeps MTU on the list. A local error means the kernel refuses to send that size on this route, either because your own interface is smaller than what you asked for or because the kernel already learned a smaller path MTU from an earlier ICMP message:
ping: local error: message too long, mtu=1492A reply from a router in the middle hands you that router's limit directly. Retest at that size before you rely on it, because a smaller link further along the path can still reject it:
From 203.0.113.1 icmp_seq=1 Frag needed and DF set (mtu = 1492)100% packet loss at 1472, with clean replies at a smaller size, is the black hole case. No router is telling you anything, so find the edge by halving. Hold one size you know works and one you know fails, test the midpoint, and move whichever bound the result belongs to. Each round halves the remaining range, so five or six rounds is enough.
A worked bisection, one round at a time
Each line is a command you run on the client against the server's public address. The comment records what came back.
ping -M do -s 1472 -c 3 203.0.113.10 # 100% loss, so 1500 is too big
ping -M do -s 1272 -c 3 203.0.113.10 # replies, so 1300 fits
ping -M do -s 1372 -c 3 203.0.113.10 # replies, so 1400 fits
ping -M do -s 1422 -c 3 203.0.113.10 # 100% loss, so 1450 is too big
ping -M do -s 1397 -c 3 203.0.113.10 # 100% loss, so 1425 is too big
ping -M do -s 1384 -c 3 203.0.113.10 # 100% loss, so 1412 is too bigThe largest payload that survived is 1372, so this path carries at least 1400 bytes and fewer than 1412. Take the safe end. A path MTU of 1400, minus 80 bytes of encapsulation, gives a wg0 MTU of 1320.
tracepath discovers the path MTU using UDP probes, and it is worth one run before you start bisecting:
tracepath -n 203.0.113.10Its last line reports what it found:
Resume: pmtu 1492 hops 12 back 12Treat both tools as a starting point rather than proof. Some hosts rate limit or drop ICMP entirely, so a bisection can report a smaller MTU than the path really carries. The transfer that was failing is the real test.
Apply the value live first, because a wrong guess is then one command away from undone:
sudo ip link set mtu 1320 dev wg0Retry the transfer that was hanging. If it completes, make the value permanent in the client's [Interface] block:
[Interface]
PrivateKey = <client private key>
Address = 10.8.0.2/32
MTU = 1320sudo wg-quick down wg0 && sudo wg-quick up wg0
ip link show wg0ip link show wg0 should now print mtu 1320. If it still prints the old value, check two things. First, check that you edited /etc/wireguard/wg0.conf, the file wg-quick reads first. Second, check whether that file contains SaveConfig = true. With it set, wg-quick down rewrites the file from the running interface and overwrites your edit, so bring the interface down first, then edit, then bring it up. MTU belongs under [Interface]. Under [Peer] it is not ignored: wg-quick passes every peer line on to wg, which rejects any key it does not recognise in a peer section, so wg-quick up stops with a parse error and the tunnel does not come up at all:
Line unrecognized: `MTU=1320'MTU is a property of one interface and it is never negotiated between peers. Setting it on the client shrinks the packets the client sends and can also reduce incoming TCP segments through the receive MSS advertised in new connections. The server keeps its own wg0 MTU, so UDP downloads and existing TCP connections can still black-hole after uploads start working. Set the value at both ends, or clamp MSS on the server using a route MTU that reflects the measured tunnel limit.
Why MSS clamping fixes TCP and nothing else
If the server forwards traffic for its peers, which it does in any standard WireGuard VPS setup using NAT (network address translation), MSS clamping uses the server's route MTU to limit TCP segments for forwarded connections. Set the server's wg0 MTU to the measured value first, because clamping does not discover a hidden smaller link for you.
MSS (maximum segment size) is a TCP option each side puts in its SYN packet to state how large a segment it is willing to receive. Clamping rewrites that option in flight to match the real route MTU, limiting the segment size advertised for each direction before any data moves. It works because it happens during the handshake, and because it does not depend on an ICMP message the path is probably filtering.
With nftables, add this table to /etc/nftables.conf below your existing tables:
table inet mangle {
chain forward {
type filter hook forward priority mangle; policy accept;
tcp flags syn counter tcp option maxseg size set rt mtu
}
}Reload with sudo systemctl reload nftables. On an iptables box the equivalent is one line:
sudo iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtuConfirm the rule is on the path the packets take. Run sudo nft list table inet mangle or sudo iptables -t mangle -L FORWARD -n -v while a client opens new connections, and watch the counter rise. A counter stuck at zero means the packets are not passing through that hook, so the rule is doing nothing.
Now the honest limits. Clamping covers TCP and nothing else, and it covers forwarded traffic only, so a service running on the WireGuard server itself never crosses the forward hook and is never clamped. It also affects connections opened after the rule loads: existing sessions keep the MSS values already advertised.
UDP is untouched, because UDP has no handshake to rewrite. Most UDP traffic survives anyway. QUIC, the transport under HTTP/3, recommends path MTU discovery; implementations without it are advised to keep UDP payloads within the 1200 byte baseline. What does not survive is UDP that sends one large datagram and expects it through, such as a DNSSEC (DNS security extensions) answer larger than the tunnel path can carry. A truncated DNS reply tells the resolver to retry over TCP, but a lost UDP reply does not guarantee that fallback, so these failures cause slow or failed lookups.
Is my VPS CPU the limit?
WireGuard encrypts with ChaCha20-Poly1305 and exchanges keys with Curve25519. There is no AES anywhere in the data path, and that has one consequence people get wrong: the AES-NI instructions in your CPU do nothing for WireGuard. A host advertising AES-NI is not offering you a WireGuard performance feature. ChaCha20 was chosen because it is fast in plain software, including on CPUs with no crypto acceleration at all.
That does not make WireGuard free. On a 1 vCPU VPS, one core handles both the encryption and the network interrupts, on top of whatever your application is doing.
Measure it while a transfer runs:
sudo apt install -y sysstat
mpstat -P ALL 1Read three columns. %soft is softirq time, which includes networking, timers, block I/O, scheduling and RCU work. %steal is guest CPU time needed but not provided by the host. %idle is what is left over. If %idle is low on a core while %soft and %steal are not high, the time is going to %usr (applications, including a userspace WireGuard) or %sys (the kernel), so read those before you rule the CPU out.
%soft near 100 on your only core means softirq work is consuming that core; it does not identify packet processing as the cause. Check which softirq activity rises during the transfer before blaming networking. More cores help only when the limiting work can spread across them; packets from one flow can remain on one CPU. Softirqs also run directly on interrupt exit, so high %soft does not require ksoftirqd/0 to top the top process list.
High %steal means the guest is waiting for CPU time the host has not provided; oversubscription, CPU allocation and scheduling priority need investigation. Steal time from a noisy neighbour needs its own investigation, and no MTU value will help with it.
One more factor is which implementation the client runs. The Linux kernel module is the fast path and it spreads a peer's encryption across cores. wireguard-go, the userspace implementation, is slower, and it is what the macOS and iOS apps use through Apple's Network Extension framework.
Is it the path, or the peer's own link?
Before tuning anything, take two numbers from the same client minutes apart: throughput without the tunnel, and throughput with it. Without that pair you are guessing.
Run iperf3 -s on the server. The direct test needs TCP 5201 reachable on the public address, so open it for the duration and remove the rule afterwards. Confirm the port is closed again rather than assuming it.
# on the client, outside the tunnel
iperf3 -c 203.0.113.10
# then through the tunnel
iperf3 -c 10.8.0.1If the two numbers are close, the tests show similar throughput, but they do not establish that the path is the limit: either test can be CPU-limited. Check CPU use on both endpoints during both tests. If the tunnel number sits far below the direct number while every core kept plenty of %idle, check for CPU quota throttling of the application or userspace tunnel before returning to MTU. Fragmentation reduces throughput without breaking anything, so it appears here as a percentage loss rather than a hang.
Test both directions, because home connections are usually asymmetric. iperf3 -c 10.8.0.1 -R reverses the flow so the server sends. A client on a 500/20 line will never push more than its 20 Mbit upload into the tunnel, and no server-side change alters that.
Then test with parallel streams:
iperf3 -c 10.8.0.1 -P 4If four streams together move much more than one, a single TCP connection is failing to fill the path. That can also be a CPU limit: starting with iperf3 3.16, each test stream runs in a separate thread, so parallel streams can spread the test's CPU work across cores. Throughput of one stream is bounded by the receive window divided by the round trip time, so a 150 ms path needs a large window to carry much data. Read your own limits:
sysctl net.ipv4.tcp_rmem net.ipv4.tcp_wmemThe third value in each is the maximum Linux will autotune to. Packet loss caps a single stream hard as well, because loss is what TCP congestion control reacts to, and a long path makes recovery expensive. Run mtr -rwc 100 203.0.113.10 from the client for a hundred cycles to see where loss appears along the route. Loss that starts at one hop and continues to the final hop is real. Loss at one middle hop that disappears after it is that router deprioritising ICMP, and it means nothing.
For a repeatable picture of the server itself, separate from the network, benchmark the VPS with a documented method so you can run the same test again after a change and compare like with like.
What WireGuard cannot fix
WireGuard is a tunnel. It cannot be faster than the slowest link on the path it uses, and its encapsulation adds overhead.
It does not compress. There is no equivalent of OpenVPN's comp-lzo. Most bulk data is already compressed, so this costs you nothing in practice. It is one of the real differences to weigh when you compare WireGuard against OpenVPN, and it is a deliberate design choice.
A full tunnel changes the route every packet takes. Traffic that used to run from you to a nearby CDN (content delivery network) now runs from you to your VPS and then to the CDN. If the VPS is on another continent, every request pays that detour and the round trip time grows accordingly. No config value shortens it. Move the VPS closer, or use a split tunnel so only the traffic that needs the VPN takes the long way. With wg-quick, AllowedIPs supplies the routes by default, and cryptokey routing explains how that decision is made.
Provider limits sit outside the tunnel and they are easy to forget. Check your plan's monthly bandwidth allowance and what happens when it runs out. Check your panel before you spend an evening on MTU.
PersistentKeepalive is not a throughput tuning control. It exists to hold a NAT mapping open so the server can still reach a client behind a home router. An interval of 25 seconds works with many firewalls, but a NAT with a shorter UDP timeout needs a shorter interval to prevent the mapping from expiring.
Measure in this order
- Reproduce the problem and note whether it is a hang or an even slowdown. A hang points at MTU. An even slowdown does not.
- Bisect with
ping -M dofrom the client to the server's public address, and write down the path MTU. - Subtract 80, set that MTU on wg0 at both ends, and retest the transfer that was failing.
- Add MSS clamping on the server if it forwards traffic for peers.
- Run
mpstat -P ALL 1during a transfer and read%soft,%stealand%idle. - Run
iperf3outside the tunnel and inside it, in both directions, single stream and with-P 4. - Run
mtr -rwc 100to the server and look for loss that persists to the last hop.
Change the server plan only after CPU measurements identify a limit the new plan addresses, or after your provider confirms that a larger plan also gets a faster network port. Steps 1 through 4 cost nothing and resolve most reports of a slow tunnel.
FAQ
Why is my WireGuard tunnel fast for ping but slow for downloads?
That split is the signature of an MTU problem. Small packets fit under every link on the path, so ping and an SSH login work. A bulk transfer sends full size segments, the encapsulated version of those is larger than some link accepts, and if that router drops them without an ICMP message getting back, nothing reports the loss and the transfer hangs. Find the path MTU with a ping -M do bisection to the server's public address, subtract 80 bytes for the encapsulation, and set the result as the wg0 MTU at both ends.
What MTU should I set for WireGuard?
There is no universal number, which is exactly why the default of 1420 fails for some people. 1420 is 1500 minus 80 bytes of WireGuard header, UDP header and outer IPv6 header. A path below 1500 bytes does not automatically require reducing 1420: with IPv4 endpoints, a 1420 byte inner packet produces a 1480 byte outer packet, which fits a 1492 byte PPPoE path. Measure your path MTU first, then subtract 60 for IPv4 endpoints or 80 for IPv6 endpoints; subtracting 80 covers either outer address family.
Does MSS clamping replace setting the MTU?
No. Clamping rewrites the MSS option in the TCP handshake so both ends send smaller segments, which fixes TCP without touching the interface. UDP has no handshake to rewrite, so it is unaffected. Clamping also applies only to traffic the server forwards, so a service running on the WireGuard server itself does not benefit. Use both: a correct MTU on the interface, and clamping to catch peers whose configuration you do not control.
Will a faster VPS plan make WireGuard faster?
Only if it addresses the CPU limit you measured, or if your provider gives larger plans a faster network port. Start with mpstat -P ALL 1 while a transfer is running. %soft near 100 means softirq work is consuming the core; identify the work before blaming packet processing, and check whether it can spread across more cores. High %steal calls for investigating host CPU contention, allocation and scheduling priority. If %idle is low while those two are not high, check %usr and %sys before you rule the CPU out. Plenty of %idle does not exclude CPU quota throttling of an application or userspace tunnel process; exhausted quota stops those threads until it is replenished.
Why is my Mac slower than my Linux client on the same network?
The Linux client uses the in-kernel WireGuard module, which processes packets in kernel space and spreads a peer's encryption across CPU cores. The macOS and iOS apps use wireguard-go, a userspace implementation, through Apple's Network Extension framework. Userspace copies each packet between the kernel and the application, and that copying costs throughput.