Port 51820 (WireGuard)

Port 51820 is known as the conventional port of WireGuard, a modern, fast VPN protocol that is simple to configure and runs over UDP.

Key facts

Port
51820
Protocols
UDP
Range
Dynamic port (Dynamic/Private), 49152-65535
Unofficial use
The use described on this page is not the IANA assignment for this port. Source (opens in a new tab) Checked on 30.11.2026

Ports in this range are not assigned to any service, and under RFC 6335 they are meant for private or temporary use.

About port 51820

Port 51820 is known as the conventional port of WireGuard, a modern, fast VPN protocol that is simple to configure and runs over UDP. The port is in the dynamic range (49152 to 65535), which IANA does not assign to services, so it has no entry in the IANA port registry.

Common use (unofficial): in WireGuard, the ListenPort setting is optional, and when it is missing, a random port is chosen at every start. Port 51820 appears in the examples in the WireGuard documentation, for example on the quick start page and in the wg and wg-quick manual pages, which is why it is the common choice on servers. You can configure any other free UDP port.

What port 51820 is used for

  • Remote access for employees: computers and phones connect to a WireGuard server and get into the office network or internal servers.
  • Site-to-site connections: two offices or two servers are connected by a permanent encrypted tunnel.
  • Server management: management ports such as port 22 stay closed to the internet and are reachable only from inside the tunnel.

The port is set in the interface configuration file, for example /etc/wireguard/wg0.conf, in the ListenPort = 51820 line of the [Interface] section.

Port 51820 in the firewall

On a WireGuard server, open the port set in ListenPort, over UDP:

  • UFW: ufw allow 51820/udp
  • firewalld: firewall-cmd --permanent --add-port=51820/udp

In a site-to-site connection with fixed addresses, you can allow the port only from the other side's address:

  • UFW: ufw allow from 203.0.113.10 to any port 51820 proto udp
  • firewalld: firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="51820" protocol="udp" accept'

A client that only connects to the server doesn't need an open incoming port.

Risks and security

WireGuard authenticates every packet by key and doesn't answer unrecognized packets at all, so a regular port scan won't detect it. A few simple habits keep the connection safe:

  • Keep the private key (PrivateKey) in a file that only root can read, for example with chmod 600 /etc/wireguard/wg0.conf.
  • Give each client only the addresses it needs in AllowedIPs.
  • Create a separate key pair for each device, and immediately delete the peer of a device that was lost or is no longer in use.
  • Install updates for the operating system and the WireGuard tools regularly.

Commands to check and configure

  • wg show

    Shows all WireGuard interfaces, the port each interface listens on and the connected peers (requires root privileges).

  • wg show wg0 listen-port

    Shows only the port the wg0 interface is listening on.

  • wg show wg0 latest-handshakes

    Shows when each peer last completed a handshake with the server. A value of 0 means no connection has been made yet.

  • wg-quick up wg0

    Brings up the wg0 interface from the /etc/wireguard/wg0.conf file.

  • systemctl enable --now wg-quick@wg0

    Brings up the wg0 interface now and at every server boot.

  • ufw allow 51820/udp

    Opens UDP port 51820 to incoming traffic (UFW).

  • firewall-cmd --permanent --add-port=51820/udp

    Opens UDP port 51820 in firewalld. Then run firewall-cmd --reload.

Port 51820 FAQ

Does WireGuard have to use port 51820?

No. 51820 is the port that appears in the WireGuard examples, but you can set any free UDP port in ListenPort. When you change the port, also update the firewall and the Endpoint line on the clients.

How do I check that a client is really connected to the server?

Run wg show on the server. Next to each connected peer, you see the time of the latest handshake and the amount of data transferred. When there is no handshake, check that the port is open in the firewall and that the public keys match on both sides.

Does WireGuard work on phones too?

Yes. There are official WireGuard apps for Android and iOS, and you can import the settings into them from a file or a QR code. The connection stays up when switching between Wi-Fi and a mobile network.

How do I set up a WireGuard server?

Create a key pair with wg genkey and wg pubkey, write the /etc/wireguard/wg0.conf file with the address, the port and the peers, open the port in the firewall and bring it up with wg-quick up wg0. The WireGuard commands page details all the steps.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement