📢 LordCloud support has moved to Ballastra — Join now →
Infrastructure & Networking

How to Check if a Port Is Open on Your Server

A port can be blocked in four different places. Here is how to check if a port is open, read the result correctly, and find which layer is the culprit.

LordCloud Engineering

Infrastructure & Support Team

Published · 6 min read
On this page

To check if a port is open on your server, run ss -tulnp on the server to confirm something is listening, then test from a different machine with nc -zv SERVER_IP PORT (Linux/macOS) or Test-NetConnection -ComputerName SERVER_IP -Port PORT (Windows). If the second test connects, the port is open end to end. If it does not, the failure is in a firewall or in how the service is bound.

The reason this needs two steps is that "open" is not one thing. A port is reachable only if a program is listening, it listens on an address your traffic can reach, and every firewall between you and it allows the packet. This guide walks through each check in order so you find the broken layer instead of guessing. If you run a VPS, a game server or a web app, you will do this more often than you expect.

What "open port" actually means#

A port is just a number (0–65535) that the operating system uses to hand incoming traffic to the right program. When people say a port is open, they usually mean three conditions are all true:

  1. A process is listening on that port.
  2. It is listening on an address the client can reach (not only the loopback address).
  3. No firewall drops the traffic on the way in.

Nmap's documentation defines the states you will see in results: open means a service is actively accepting connections, closed means the port is reachable but nothing is listening, and filtered means a firewall or filter is blocking the probes so the state cannot be determined. Those definitions are in the Nmap port scanning basics reference, and they map neatly onto the troubleshooting below. If you need a refresher on protocols first, our TCP and UDP ports doc covers the basics.

Step 1: Check what is listening on the server#

Log in over SSH (see connecting through SSH if you need it) and run:

bash
sudo ss -tulnp

The flags, from the ss manual page: -t shows TCP sockets, -u UDP sockets, -l only listening sockets, -n skips name resolution so you see numbers, and -p shows the owning process (needs root to see other users' processes).

You will get lines like this:

text
Netid State  Local Address:Port  Process
tcp   LISTEN 0.0.0.0:22          users:(("sshd",pid=812,fd=3))
tcp   LISTEN 127.0.0.1:3306       users:(("mysqld",pid=977,fd=21))
tcp   LISTEN *:25565              users:(("java",pid=2310,fd=98))

Read the Local Address column carefully, because it explains most "port is open but I cannot connect" tickets:

  • 0.0.0.0:22 or *:25565 means listening on all IPv4 interfaces. Reachable from outside, subject to firewalls.
  • 127.0.0.1:3306 means loopback only. Nothing from the internet can reach it, by design. MySQL does this by default on many setups, which is a good thing.
  • [::]:80 is the IPv6 equivalent of all interfaces.

If your port is not in the list at all, the service is not running or crashed. Fix that first; no firewall change will help. Filter quickly with sudo ss -tulnp | grep :25565.

Step 2: Check if a port is open from outside#

Testing from the server itself proves very little, because local traffic skips the external firewall path. Use your laptop, a second server, or your phone's hotspot.

Linux and macOS: nc (netcat)#

bash
nc -zv 203.0.113.10 25565

-z scans without sending data and -v prints the result. A success message such as "succeeded" or "open" means the TCP handshake completed. "Connection refused" means closed. A hang until timeout usually means filtered. Flag behaviour differs slightly between netcat variants, so check man nc on your system. For UDP add -u, but see the caveat below.

Windows: Test-NetConnection#

powershell
Test-NetConnection -ComputerName 203.0.113.10 -Port 25565

PowerShell's cmdlet, documented on Microsoft Learn, reports TcpTestSucceeded : True when the TCP connection works. Add -InformationLevel Quiet if you only want True or False. It tests TCP only.

Any OS: nmap#

bash
nmap -p 25565 203.0.113.10
nmap -p 22,80,443,25565 203.0.113.10

Nmap gives you the state names above, which helps you tell closed from filtered. Only scan servers you own or have permission to test.

Closed vs filtered: reading the result#

Result Meaning Look at
open Handshake completed Nothing, it works
closed / connection refused Server answered, nothing listening The service: running? right port?
filtered / timeout Probe dropped, no reply Firewalls on the host and in front of it

The distinction saves time. A fast "refused" means packets reached the machine, so skip firewall hunting and check the service. A slow timeout means packets never got an answer, so look at firewalls.

Fixing a port that is not open#

Work through these in order.

1. Service not running. Check with systemctl status yourservice or your game panel console. Start it and re-run ss.

2. Bound to the wrong address. If ss shows 127.0.0.1, change the service's bind or listen setting to 0.0.0.0 (or the public IP). For Minecraft, server-ip in server.properties should usually be left blank. Only expose databases publicly if you truly must, and restrict by IP.

3. Host firewall. On Ubuntu with UFW:

bash
sudo ufw status verbose
sudo ufw allow 25565/tcp

Rules are protocol specific, so a UDP game port needs /udp. Our firewall configuration guide covers VPS setups, and if you use Docker, read why published ports bypass UFW because Docker edits iptables directly and the UFW status may mislead you.

4. Firewall or panel outside the OS. Some providers and dashboards have their own firewall or port-allocation layer in front of the server. Check your control panel's network or firewall section, and confirm the port is actually assigned to your service.

5. Wrong IP or port on your end. Double-check the public IP, and remember that a client-side network such as a college or office Wi-Fi may block outbound ports. Test from mobile data to rule that out. This is common on Indian campus and corporate networks.

6. DNS or SRV confusion. If the IP works but your domain does not, the port may be fine and DNS is the problem. See SRV records and our post on Minecraft SRV records.

Checking UDP ports#

UDP has no handshake. A TCP scan gets a clear answer; a UDP probe that gets no reply could mean the port is open, or that a firewall dropped the packet. Nmap reports this as open|filtered. So for UDP, verify in two steps: confirm with ss -ulnp that the service is listening, then test with the real client (a game, a voice server, a VPN client). Many games use UDP for gameplay and TCP for query or RCON, so open both if the docs say so.

A quick checklist you can reuse#

  1. sudo ss -tulnp | grep :PORT shows LISTEN on 0.0.0.0 or *?
  2. sudo ufw status (or your firewall tool) allows the port and protocol?
  3. Provider or panel firewall allows it?
  4. nc -zv IP PORT from another network succeeds?
  5. Domain resolves to the same IP you tested?

If all five pass and a client still fails, the problem is above the network layer: version mismatch, authentication, or an application error in the logs.

When to ask support#

If the service listens correctly and your own firewall allows the traffic but outside tests still time out, collect the ss output, the exact command you ran and its result, and your public IP. With that, a ticket can be resolved far faster; see how to create a support ticket. If you are looking for a server to practise on, you can compare VPS hosting plans and read the network troubleshooting doc alongside this guide.

FAQ#

How do I check if a port is open on my server?#

Run ss -tulnp on the server to confirm a listener, then nc -zv IP PORT or Test-NetConnection from another machine. Both succeeding means the port is open.

What is the difference between a closed and a filtered port?#

Closed means the host answered and nothing listens there. Filtered means a firewall swallowed the probe, so there was no answer.

Why does a port show as open on the server but closed from outside?#

Usually the service binds to 127.0.0.1 only, or a host or provider firewall blocks inbound traffic.

How do I check if a UDP port is open?#

Confirm the listener with ss -ulnp and test with a real client, since UDP scans often return only open|filtered.

Scan only systems you own or are authorised to test.

Frequently asked questions

How do I check if a port is open on my server?

On the server, run ss -tulnp to see what is listening. From another machine, run nc -zv SERVER_IP PORT, or Test-NetConnection -ComputerName SERVER_IP -Port PORT on Windows. If both succeed, the port is open end to end.

What is the difference between a closed and a filtered port?

Closed means the machine answered but nothing listens on that port. Filtered means a firewall dropped your probe, so you got no answer at all. Closed points at the application; filtered points at a firewall.

Why does a port show as open on the server but closed from outside?

The service is probably bound to 127.0.0.1 only, or a firewall (host or provider-level) is blocking inbound traffic. Check the listening address in ss output, then your firewall rules.

How do I check if a UDP port is open?

UDP has no handshake, so a scan cannot always tell. Confirm the service is listening with ss -ulnp, then test with a real client. nmap reports such ports as open|filtered when no reply comes back.

Is it legal to scan ports with nmap?

Scan only servers you own or have permission to test. Checking your own VPS or game server is fine; scanning other people's machines can breach their terms or local law.

References

Drafted with AI assistance and checked against LordCloud's published product information. Spotted a mistake?Suggest an edit.

All articles →
Have a question? Chat with us👋