Back to blog

How to Check Whether Your VPN Port Is Open (UDP and TCP)

November 8, 2026 3 min read

When a new VPN won't connect, a closed port is the first suspect, and it's the hardest to prove. WireGuard and AmneziaWG use UDP, and UDP doesn't answer when you knock the way TCP does. Here is how to check each layer properly, so you stop guessing.

Three layers can block a port

A packet from your phone to your server passes three checkpoints, and any one can stop it:

  1. The host's firewall: security groups, security lists or firewall rules set in your provider's control panel, outside the server.
  2. The server's own firewall: ufw on Ubuntu, firewalld on AlmaLinux, Rocky and CentOS, or plain iptables rules.
  3. The VPN program itself: it has to be running and listening on the port.

Check from the inside out.

Layer 3: is the VPN listening?

On the server:

sudo ss -tulpn | grep -E '51820|443'

You should see the VPN's process on the port: UDP 51820 for WireGuard and AmneziaWG, TCP 443 for VLESS (the defaults on Nullsify servers). Nothing listed means the service isn't running, so no firewall change will help. If a different program owns the port, that's the "address already in use" problem.

Layer 2: the server's firewall

sudo ufw status
sudo firewall-cmd --list-all
sudo iptables -S INPUT

Only the one your system uses will answer. Look for your port. If it's missing, allow it:

sudo ufw allow 51820/udp
sudo firewall-cmd --permanent --add-port=51820/udp && sudo firewall-cmd --reload

Nullsify opens its ports in ufw, firewalld and iptables during setup, so this layer is usually fine on a server it installed. On a hand-built one, it's the usual culprit.

Layer 1: the host's firewall

Your provider's panel is the only place to see this one, and no command on the server can reveal it. Open the firewall, security group or security list for the server and confirm an inbound rule for the port and protocol. Alibaba Cloud and Oracle Cloud block everything inbound by default, so there you always have to add rules. See the Oracle Cloud walk-through.

Testing a TCP port (VLESS)

TCP ports are easy to test from your own computer. On Windows:

Test-NetConnection 203.0.113.24 -Port 443

On macOS or Linux:

nc -vz 203.0.113.24 443

A success proves the whole path is open. Online port checkers work too, for TCP only.

Testing a UDP port (WireGuard, AmneziaWG)

This is where people get fooled. A UDP port scan can't tell "open" from "blocked", because a listening WireGuard server never replies to packets it doesn't recognize. The scanner sees silence either way, and nc -vzu often reports success regardless of what's happening.

The reliable test is to watch the packets arrive. Install tcpdump on the server and run:

sudo apt install tcpdump
sudo tcpdump -ni any udp port 51820

Now try to connect from your phone or computer. Then read the result:

  • Packets appear: the port is open all the way to the server. The problem is further in: keys, the VPN service, or the config. Try handshake did not complete for those.
  • Nothing appears: the packets never arrive. A firewall in front of the server is dropping them, or the client's Endpoint is wrong. Recheck the host's firewall and the IP in the config.
  • Packets appear only on Wi-Fi, not on mobile data: your carrier is blocking UDP or the protocol. That's a different problem, and the answer is a protocol that looks like web traffic.

Press Ctrl+C to stop tcpdump.

What to do with the answer

Once you know which layer is closed, the fix is one setting. If all three are open and the connection still fails, work through the debugging checklist, and see firewall basics for your VPS for how these layers fit together.

Ready to run your own VPN?

Bring your own VPS and have VLESS, AmneziaWG, or WireGuard running in minutes — no manual setup required.