VPNSmith
self-host-vpnINFO

WireGuard Default Port: UDP 51820, and How to Open, Forward or Change It (2026)

WireGuard's default port is UDP 51820. What that means, how to open it in your firewall, forward it through your router, change it to a custom port, and fix the connection problems the port causes.

By Eric Gerard · Founder · VPNSmith - Self-host VPN & GDPR VPS specialist6 min readPhoto via Pexels

WireGuard's networking is refreshingly simple - but the one number that trips people up is the port. By default WireGuard listens on UDP 51820, and almost every "my self-hosted VPN won't connect" problem comes down to that port not being open, not being forwarded, or not matching the client config. This guide covers the default, how to change it, and how to open and forward it correctly.

WireGuard ports at a glance

The short answer: WireGuard uses UDP port 51820 by default - that is its standard port, set by the ListenPort line. There is no TCP mode at all. The ports that matter:

PortProtocolRole
51820UDPWireGuard's default (standard) listening port
Any 1-65535UDPA custom port you choose with ListenPort
443UDPCommon alternative to slip past restrictive firewalls

The client's Endpoint = <public-ip>:<port> must use the exact same port as the server's ListenPort - that mismatch is the single most common reason a self-hosted WireGuard tunnel won't connect.

The default: UDP 51820

WireGuard listens on UDP port 51820 by convention, set by the ListenPort line in the server's [Interface] section. Two things matter here:

  • It's UDP, not TCP. WireGuard has no TCP mode at all. Firewalls or networks that block UDP will stop it cold.
  • 51820 is just the default, not a rule - you can use any free UDP port from 1 to 65535.

Clients reach the server using the Endpoint = <public-ip>:51820 line in their own config. That port has to match the server's ListenPort exactly.

A network switch with rows of numbered ports
A network switch with rows of numbered ports

Picking a port: is 443/UDP worth it?

Any free UDP port from 1-65535 works, but a few choices are smarter than others:

  • Keep 51820 for simplicity if your network doesn't filter UDP - it's the documented default and easiest to support.
  • Use UDP 443 if you're on a restrictive network. Port 443 is the HTTPS port, and modern web traffic (HTTP/3 / QUIC) already runs over UDP 443, so a WireGuard tunnel there blends into normal-looking encrypted traffic and slips past many port-based blocks. It's the single most useful port change. Note this is port-level camouflage only - deep packet inspection can still fingerprint the handshake (see the stealth section below).
  • Avoid ports below 1024 unless you have a reason; they're "privileged" and need root, with no upside here.

Opening the port in the firewall

On the server, the port must be allowed for UDP. With UFW:

sudo ufw allow 51820/udp
sudo ufw reload

With iptables it's -A INPUT -p udp --dport 51820 -j ACCEPT. This is the single most common cause of a server that "runs" but never accepts connections: the WireGuard service is up, but the firewall silently drops the packets.

Forwarding the port through a router

Where your server lives decides whether you also need port forwarding:

  • On a VPS (a rented server with a public IP): no forwarding needed - the firewall rule is enough, because the public IP points straight at the machine.
  • On a home server behind a router: add a port-forward rule in the router admin - forward UDP 51820 (external) to the server's local IP on UDP 51820 (internal). Without it, packets from the internet never reach the server.

Test from outside your network (e.g. a phone on mobile data, Wi-Fi off): a client should reach server-public-ip:51820. If it works on your LAN but not from outside, forwarding is the missing piece.

Changing the port

To use a different port, set it in the server's [Interface]:

[Interface]
ListenPort = 51821

Then restart the tunnel (systemctl restart wg-quick@wg0) and update everything that referenced the old port:

  1. the firewall rule (allow the new UDP port),
  2. the router forward (if applicable),
  3. the Endpoint line in every client config.

Miss any one and clients won't connect. A self-hosted VPS makes all of this straightforward because you control the firewall and the public IP directly. If you're editing the config from scratch, our ready-to-use WireGuard config templates give you a correct [Interface]/[Peer] skeleton with the ListenPort and Endpoint lines already in the right place.

★ Nuremberg GDPR datacenter · ✓ Dedicated IPv4 included · 200+ Mbps guaranteed

A VPS with a public IP - no router forwarding needed → ContaboPublic IPv4 · You control the firewall and port · Host WireGuard reachably from anywhere

Verify the port is actually listening

Before blaming the client, confirm the server really listens on the port you think it does:

sudo wg show              # shows the interface and its listening port
sudo ss -lunp | grep 51820   # is something bound to UDP 51820?

wg show lists the active listening port; ss -lunp (note the u for UDP) proves a process is bound to it. If wg show reports a different port than your config, the service didn't reload after your edit - restart it. From another machine you can probe reachability with nc -uvz server-ip 51820, though UDP probes are unreliable, so a real client handshake is the definitive test.

Running more than one tunnel

Each WireGuard interface needs its own ListenPort. If you run, say, wg0 for general traffic and wg1 for a separate group of peers, give them distinct ports (e.g. 51820 and 51821), open and forward both, and point each client at the right one. Two interfaces sharing a port silently fail to start.

Does changing the port hide your VPN?

A non-default port reduces noise from bots that scan 51820, but it is not stealth. Deep packet inspection fingerprints WireGuard's distinctive UDP handshake regardless of the port number. If you need to get through a firewall that actively blocks or detects VPNs, you need obfuscation (wrapping the tunnel), not just a different port - see WireGuard with port knocking / stealth, or compare the tools that actually wrap the tunnel in sing-box vs Xray. For routing specific traffic or forwarding services through the tunnel, see port forwarding.

The bottom line

WireGuard uses UDP 51820 by default - UDP only, no TCP. To make a self-hosted server reachable: open the port for UDP in the firewall, forward it on the router if the server is behind one (a VPS with a public IP skips that), and make sure every client's Endpoint matches. Change the port if you like for less scan noise, but treat it as light hardening, not real stealth.

Once you have settled on a port, our free WireGuard config generator builds a matching server and client config in your browser, with the ListenPort and Endpoint already lined up.

★ Nuremberg GDPR datacenter · ✓ Dedicated IPv4 included · 200+ Mbps guaranteed

Self-host your VPN on your own VPS → ContaboFull root access · public IPv4 · pick your region

Frequently asked questions

What port does WireGuard use by default?
WireGuard listens on UDP port 51820 by default. It is the conventional port set by the `ListenPort` option in the interface config (wg0.conf), and it is UDP only - WireGuard does not use TCP at all. The default is just a convention, not a requirement: you can set any free UDP port between 1 and 65535. For a server that needs to be reachable from the internet, the chosen port must be open in the server's firewall and, if the server sits behind a router, forwarded to it. Clients connect to the server's public address on that exact port (the `Endpoint` in their config).
Is the WireGuard port TCP or UDP?
UDP, always. WireGuard is designed around UDP and has no TCP mode - that's part of why it's fast and simple, but it also means firewalls that only allow TCP, or networks that block UDP, will stop it. The default UDP 51820 is what you open and forward. If you're on a restrictive network that blocks UDP (some corporate or public Wi-Fi, censored countries), plain WireGuard won't connect; you then need to tunnel it over something else (e.g. a TCP-based obfuscation layer) rather than just changing the port number.
How do I change the WireGuard port?
Edit the `[Interface]` section of your server config (typically /etc/wireguard/wg0.conf) and set `ListenPort = <your-port>`, then restart the tunnel (`wg-quick down wg0 && wg-quick up wg0`, or `systemctl restart wg-quick@wg0`). You must also update three things to match: open the new port in the server firewall, forward the new port on the router if applicable, and change the `Endpoint = server-ip:<your-port>` line in every client config. If any of those still points at the old port, clients won't connect. Changing the port doesn't add real security on its own - it only reduces noise from automated scanners.
How do I open and forward the WireGuard port?
Two layers. On the server firewall, allow the port for UDP - e.g. with UFW: `sudo ufw allow 51820/udp`. If the server is behind a home router (not a VPS with a public IP), add a port-forwarding rule in the router admin: forward UDP 51820 (external) to the server's local IP on UDP 51820 (internal). A VPS from a provider usually has a public IP directly, so you only need the firewall rule, not router forwarding. After that, test from outside your network - a client on mobile data should be able to reach `server-public-ip:51820`.
Should I change the default WireGuard port to hide my VPN?
Changing the port to a non-default value cuts down log noise from bots that scan 51820, but it is not real stealth - a network that does deep packet inspection can still fingerprint WireGuard's distinctive UDP handshake regardless of the port. So a different port is fine as light hardening, but if your goal is to get through a firewall that actively blocks or detects VPNs, you need obfuscation (e.g. wrapping the tunnel), not just a port change. See our guide to stealth setups for that scenario.
What is port 51820 used for?
UDP port 51820 is WireGuard's default listening port - it is the port a WireGuard server listens on (set by `ListenPort` in wg0.conf) and the port clients connect to in their `Endpoint`. It is registered by convention for WireGuard, not reserved by any other common service, and it is UDP only. If you see traffic or firewall rules referencing UDP 51820, that is almost always a WireGuard tunnel. You are free to move WireGuard to any other free UDP port, but 51820 is what it uses unless you change it.
Can WireGuard use port 443?
Yes, but only UDP 443, not TCP 443. WireGuard has no TCP mode, so you cannot literally run it over TCP 443 the way an HTTPS site does. Setting `ListenPort = 443` (and forwarding UDP 443) makes the tunnel use the same port number as HTTPS, which can slip past networks that only allow well-known ports - but a firewall doing deep packet inspection can still tell WireGuard's UDP handshake apart from real TLS. Use UDP 443 as light evasion; use a dedicated obfuscation layer if the network actively blocks VPNs.
Can I run two WireGuard tunnels on different ports, like 51821?
Yes. Each tunnel is a separate interface with its own config and its own `ListenPort`, so a second tunnel commonly uses 51821 (one above the default) while the first stays on 51820. Give each interface a distinct name (wg0, wg1), a distinct `ListenPort`, and a non-overlapping address range, then open and forward each port separately. Nothing special ties the number 51821 to WireGuard - it is just the obvious next port when you already have 51820 in use.