Insights

WireGuard port: Which UDP port to open and where to set it

WireGuard usually uses UDP port 51820. Learn which port to allow, when to leave the peer endpoint unchanged, and how to check the handshake.

Illustration of rotary chute with selectable outlet.
On this page

WireGuard commonly uses port 51820 over User Datagram Protocol (UDP), but that port isn't required. Native WireGuard doesn't use Transmission Control Protocol (TCP). Use the UDP port the receiving peer or provider specifies.

In short:

  • Allow UDP. A TCP rule doesn't allow WireGuard traffic on the same port number.
  • Dial the reachable port. Set Endpoint to the public address and port when a router forwards the connection.
  • Check the handshake. Look for a fresh handshake after sending traffic from a configured peer.

A TCP rule won't open the WireGuard port

UDP 51820 is the usual choice and the listening port shown in the WireGuard quick start. A firewall rule for TCP 51820 alone won't let WireGuard traffic through. If you use a different port, match the rule to the UDP port the firewall sees.

The port you dial and the port that listens

ListenPort is the local UDP port where the receiving WireGuard interface listens. Endpoint is the reachable address and port set on the peer that dials it. A directly reachable host needs no router forward, so its peers dial the listener's port. If a router translates the port, peers dial the router's public port instead.

Suppose your router forwards public UDP 43210 to a WireGuard host listening on UDP 51820. You want to move the listener to UDP 51821 without changing the router's public address or port. Make this change only on a router and host you manage, and start with a reachable public UDP destination. Save the old settings so you can restore them if the check fails.

  • Before: Router public UDP 43210 → WireGuard host UDP 51820
  • After: Router public UDP 43210 → WireGuard host UDP 51821

1. Move the local listener. Change the receiving interface's ListenPort to 51821. Match the host firewall rule to UDP 51821.

2. Update the router's internal forward target. Keep the public UDP port at 43210 and send that traffic to UDP 51821 on the same host.

3. Leave the dialing peer's Endpoint alone. The public address and UDP port 43210 haven't changed, so there's nothing to edit on that peer.

The change worked if the listener reports UDP 51821 and a configured peer outside your local network gets a fresh handshake using its unchanged Endpoint.

Check for a fresh handshake

A WireGuard listener can stay silent when it doesn't receive a valid WireGuard packet. No reply from a generic port checker doesn't prove the port is closed or tell you what blocked the test. Instead, use a configured peer and look for a fresh handshake, the exchange that starts an encrypted session.

1. Send traffic through the tunnel. From a configured peer, send traffic to an address it routes through WireGuard. If you're testing an internet-facing forward, use a peer on a separate network so the traffic takes the public path. Note when you started the test.

On a Linux receiving host you manage, use the WireGuard tools to read the current state without changing it.

2. Check the listening port and handshake time.

sudo wg show

Check that listening port shows the local UDP port you expect. A latest handshake for the test peer that occurred after you started the test confirms the peers reached each other. If there's no fresh handshake, first check that the peer sent traffic into the tunnel. Then check the peer's Endpoint, the receiver's ListenPort, the UDP firewall and forwarding rules, and the peer keys.

3. Test the private service separately. Connect to it using its usual address and port. A fresh handshake doesn't prove the service is reachable. If the handshake works but the service doesn't respond, check tunnel routing and the rules that control access to the service.

Where doxx.net fits. For direct WireGuard connections to the doxx.net private network, you can choose UDP 51820 (the default), 53, 443, 123 or 5353 as the remote destination port, not as a local listener or private service port. If you want to connect a device to the private network, you can download the doxx.net app.

Ask an AI assistant

Share this article

Private Everywhere

Stop giving the internet everything

Keep your browsing, messages, files, and agents private.