WireGuard: “Handshake did not complete after 5 seconds”
WireGuard troubleshooting
Updated
What you see
The app keeps trying to connect, or says it's connected but nothing loads. Data is sent but almost none comes back, and the log repeats a line like this:
Handshake for peer 1 (203.0.113.24:51820) did not complete after 5 seconds, retrying (try 2)
What it means
Your device sent the first message of WireGuard's handshake to the server and got no answer within five seconds, so it tries again — indefinitely. WireGuard never replies to packets it can't verify, not even with an error, so a wrong key looks exactly like a blocked port: silence. The cause is almost always one of the ones below.
Quick fix
Check the firewall first. WireGuard needs its UDP port (51820 by default) open inbound, both in the server's own firewall and in any firewall your hosting company puts in front of it. If that's open, compare the Endpoint in your config with the server's IP address and port.
Causes and how to fix them
1. The UDP port is blocked at the server
This is the most common cause. Many hosts put a firewall in front of servers — security lists on Oracle Cloud, a firewall tab on Alibaba Cloud, optional cloud firewalls elsewhere — and some servers have the ufw firewall switched on. Either one drops the handshake without a trace. Allow UDP 51820 in the hosting control panel, then on the server itself:
sudo ufw status sudo ufw allow 51820/udp
2. The endpoint is wrong
The Endpoint line in your config must be the server's public IP address and the port WireGuard listens on, like 203.0.113.24:51820. A typo, an old IP after the server was rebuilt, or a private address (10.x or 192.168.x) sends the handshake nowhere. On the server, confirm something is listening on the port:
sudo ss -ulpn | grep 51820
3. The keys don't match
The PublicKey under [Peer] in your config has to be the server's public key, and the server has to know yours. If either side changed — the server was reinstalled, or the config regenerated — the server ignores you. Get a fresh config instead of editing keys by hand. On the server, this lists the peers it accepts and when each last completed a handshake:
sudo wg show
On AmneziaWG servers, including servers set up by Nullsify, the command is sudo awg show.
4. The server isn't running WireGuard
After a reboot or a failed update, the interface may simply not be up. Check its service — the name after @ matches your config file, usually wg0:
sudo systemctl status wg-quick@wg0
5. Your network blocks WireGuard
Some networks — workplaces, schools, hotels, and whole countries — block UDP or recognize WireGuard's handshake and drop it. If the same config works on another network (try your phone's mobile data), this is the cause. Moving to another port rarely helps for long. A protocol built to avoid detection does: AmneziaWG, or VLESS + Reality if UDP is blocked entirely.
Using Nullsify?
Nullsify generates the keys for both sides, so they always match, and opens UDP 51820 in the server's own firewall during setup. A firewall run by your hosting company still needs the port opened — the setup guide for your provider shows where. If your network blocks WireGuard, switch the server to AmneziaWG or VLESS from the dashboard.
Free for 1 server. Bring your own VPS — Nullsify configures WireGuard, AmneziaWG or VLESS on it for you.
Related problems
- Connected but no internet WireGuard
- AmneziaWG won't connect AmneziaWG
- Works on Wi-Fi, not mobile data Any protocol