DEV Community

Cover image for WireGuard handshake fails on one Wi-Fi only — and it isn't the MTU
Dmytro Tishchenko
Dmytro Tishchenko

Posted on

WireGuard handshake fails on one Wi-Fi only — and it isn't the MTU

Same config file, same server. The Linux laptop connects instantly, the Android phone connects instantly, and the iPhone sits there repeating handshake did not complete. Then you switch that same iPhone to 5G and the tunnel comes straight up.

At this point almost everyone opens the WireGuard config and starts lowering the MTU. I did it too. It is a waste of an evening, and here is why.

A failed handshake is not an MTU problem

A WireGuard handshake initiation is 148 bytes. The reply is 92. Those fit inside every MTU that has ever been deployed — there is nothing to fragment. MTU governs the size of packets carried inside the tunnel, and that only matters once the tunnel exists. Before the handshake completes there is no tunnel.

So a handshake that never completes means one thing: the packets are not arriving at all. Put the MTU back to 1420 and leave it alone. The problem is the network, and the "works on 5G, fails on this Wi-Fi" clue is telling you exactly that — identical config, identical server, different result, so the only variable is the network.

Here is what actually tells you where it breaks, in order.

1. Does UDP even leave the device?

WireGuard is UDP. Plenty of Wi-Fi networks — hotels, campuses, offices, some mobile hotspots — quietly drop outbound UDP on anything that is not a well-known port.

The quick test is a STUN query, because STUN is also UDP. Run it on the Wi-Fi that fails:

  • It answers → UDP egress works, and your problem is the specific port or endpoint (see below).
  • It times out on this Wi-Fi but answers on cellular → this network is filtering UDP for your device. That is your answer.

I run the STUN / NAT tool in NetDiag+ for this: when it gets zero answers it says UDP blocked outright, and when it does get through it classifies the NAT type. Any STUN client will do — the point is to separate "UDP is blocked" from "the tunnel config is wrong", which the WireGuard log never tells you.

2. Compare what the two devices actually see

Put the iPhone's IP, subnet mask, gateway and DNS next to the laptop's, on the same Wi-Fi.

If the phone is on a different subnet or a different gateway, it did not land on the same network you think it did — it is on a guest VLAN, or the router is applying a per-device profile to it. The restriction lives on the router, not in your config, and no amount of editing the tunnel will fix it. A Wi-Fi Info readout on each device takes ten seconds and settles the question.

3. If UDP gets out, suspect the port

If UDP leaves the device but the handshake still never lands, the server's listen port is almost certainly being dropped on the way out. This is the most common cause on hotel, campus and office networks.

Move your server's listen port to 443 or 53. Traffic on those ports almost always passes, because blocking them would break the web and DNS for everyone on the network. This one change fixes a surprising share of "only on this Wi-Fi" cases.

The iOS red herrings

While you test, you will be tempted to blame iOS privacy features:

  • iCloud Private Relay, Limit IP Address Tracking, Private Wi-Fi Address — worth switching off while you narrow it down, but rarely the cause. They change which address you appear to come from; they do not decide whether a UDP packet reaches your endpoint.

Narrow it the other way instead: is UDP leaving the device, and are both devices on the same network? Answer those two and you have almost always found it.

The short version

  • Handshake fails → not MTU. Leave MTU at 1420.
  • STUN on the failing Wi-Fi: no answer → UDP is filtered.
  • Compare IP / subnet / gateway / DNS across devices → catches guest VLANs and per-device profiles.
  • Still failing → move the server port to 443 or 53.

I wrote the full checklist up, with the "what to test, in order" version and the questions people actually ask, here: why a failed WireGuard handshake on iOS is not an MTU problem.

I do the measuring from the phone with NetDiag+ (free) — STUN / NAT and Wi-Fi Info are the two I reach for here — but the method is the same with whatever you already have on the device.

Top comments (2)

Collapse
 
m_montazeri profile image
Mohammad Montazeri •

One diagnostic distinction I would change: a STUN timeout is not proof that all UDP is filtered. RFC 8489 §6.2.1 defines it as a failed transaction after unanswered retransmissions; that observation does not identify where the request or response was lost. Likewise, a successful exchange proves that particular STUN path works, not that the WireGuard endpoint is reachable.

rfc-editor.org/rfc/rfc8489.html#se...

I would label the tool result "No STUN response observed" and keep filtering as a hypothesis. For the Wi-Fi/cellular comparison, record the actual resolved endpoint address and address family, then, where you administer the endpoints, compare whether the handshake packet arrives at the server and whether a response leaves. That gives the next test a concrete boundary before changing ports or device privacy settings.

AI-assisted technical comment; I work on a VPN service.

Collapse
 
dtisch profile image
Dmytro Tishchenko • • Edited

You're right. A STUN timeout only narrows suspicion to the network path — it doesn't localize the loss or prove every UDP flow is dropped, and a successful exchange just proves that one STUN transaction got through, not that the WireGuard endpoint is reachable. I used it as a cheap first cut and wrote it up as more than that; the post reads stronger than the evidence allows.

What actually carries the weight is the contrast — same config and server, fails on one Wi-Fi, comes up on 5G — plus two confirming steps: comparing what both devices see on that Wi-Fi, and moving the listen port to 443 or 53. STUN is really just a go/no-go on whether the network is worth suspecting before I spend time there.

I've tightened the wording so it doesn't overclaim. Thanks for the RFC pointer.