GICT knowledge base
How to Accurately Test if a UDP Port is Open
Published
How to Accurately Test if a UDP Port is Open
If you have ever tried to troubleshoot a connection on your InterServer VPS or Dedicated Server, you probably know that UDP (User Datagram Protocol) can be a bit of a headache. Unlike TCP, which uses a “handshake” to confirm a connection, UDP just sends data and hopes for the best. This makes traditional testing a little tricky.
You might have tried using nc -vz -u [IP] [PORT] and seen a message saying “Succeeded!”—only to find out the port is actually closed. In this guide, we will show you the foolproof way to test UDP ports by using two systems to confirm data is actually moving.
The Problem with Basic UDP Scans
Most tools will report a UDP port as “open” simply because they didn’t receive an error message back. To be 100% sure your traffic is getting through, you need to see the data arrive on the destination server.
Method 1: The Two-Way Netcat Test
To do this right, you need access to both the source (the computer you are testing from) and the destination (your InterServer server).
1. On the Destination Server (The Listener)
First, tell your server to listen for incoming data on a specific port (we will use 6667 as an example). Run this command:
nc -luk x.x.x.x 6667
Note: Replace x.x.x.x with your server’s IP address. This is the destination.
2. On the Source System (The Sender)
From your local computer or a different remote system, send some data to that port:
nc -uv x.x.x.x 6667
3. Verify the Connection
Once connected, type a few characters like “XXXX” or “Hello” in the sender window and hit Enter. If the port is open and working, those characters will appear instantly on the destination server’s screen.
Method 2: Using tcpdump to Watch Traffic
If you want to see exactly what is happening at the network level, tcpdump is your best friend. This tool captures the “packets” of data as they arrive.
Run this command on your destination server to watch for incoming UDP traffic on a specific port (e.g., 8002):
tcpdump -i any udp port 8002 -nn
When you send data from the source, you will see output like this:
20:10:17.563441 eno49 In IP y.y.y.y.60234 > x.x.x.x.8002: UDP, length 1
Understanding the Output:
- y.y.y.y (Source): This is the IP address of the computer sending the request (your home IP or another server).
- x.x.x.x (Destination): This is your InterServer server’s IP address that is receiving the data.
How to Check if a Process is Already Using the Port
If your test fails, it might be because another program is already using that port. You can check this with the lsof command:
root@server:~# lsof -i :42021
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nc 2439862 root 3u IPv4 229681656 0t0 UDP server.name:42021
In this example, we can see that nc (Netcat) is successfully holding the port open. If you see your application name listed there, your service is running and ready for traffic!
Quick Summary
Don’t trust a “succeeded” message from a simple UDP scan. Always verify by:
- Setting up a listener on the destination.
- Sending a string of text from the source.
- Confirming the text appears on the other side.
If you’re still having trouble getting traffic through, feel free to reach out to the InterServer support team!
Related guides
Plan a Safe Redis-to-Valkey Migration
Plan a Redis-to-Valkey migration: check version compatibility, rehearse recovery, stop writers for cutover and protect against lost writes during rollback.
Linux AdministrationHow to Restrict an SSH Key to One Command
Restrict an SSH key to one command with authorized_keys options. Protect the command and check that unwanted shell and forwarding access are denied.
Linux AdministrationHow to Schedule Tasks with systemd Timers
Schedule tasks with systemd timers. Verify service results separately from timer status, test missed-run handling and use an explicit UTC schedule.
Linux AdministrationHow to Restrict a Linux Service with systemd Security Settings
Restrict a Linux service with systemd drop-ins, a dedicated account, read-only paths, private temporary storage, and controlled writable directories.
