A portPort A numbered door on a server. Each service listens behind its own door: web pages on 443, email on others, remote login on 22. More about Port → checker tells you whether a program on a server can be reached on a particular port, such as 443 for a website or 22 for SSH. This guide is for anyone running a site or server who needs to know whether a port is really open, and why it is not when it should be.
To check a port, connect to it from outside the server: run nc -zv example.com 443 on Linux or macOS, or Test-NetConnection example.com -Port 443 in Windows PowerShell. A success means something is listening and nothing in between is blocking it. “Connection refused” means nothing is listening, while a timeout usually means a firewallFirewall A gatekeeper that decides which connections are allowed into a server and blocks the rest. More about Firewall → is silently dropping the traffic. Then check on the server itself with sudo ss -tlnp to see what is actually listening.
What a port check actually tests
A port is a number from 0 to 65535 that directs a connection to one program on a machine. If the idea is new, read the guide to port numbers linked at the end first. A port checker tries to open a connection to an address and port, then reports what happened.
For a connection to succeed, every layer along the path has to say yes:
- A program (NginxNginx A fast, popular program that sends web pages to visitors and can pass requests on to apps behind it. More about Nginx →, sshd, a mail server) is running and listening on that port.
- It is listening on an address that outside visitors can reach, not only on the server itself.
- The server’s own firewall allows the port.
- Any firewall your host or cloud provider runs in front of the server allows it too.
- Nothing between you and the server, such as your own network or your internet provider, blocks it.
A port checker cannot tell you which layer failed. It only gives you one of three results, and each one points you to a different layer.
| Result | What the checker saw | What it usually means |
|---|---|---|
| Open | The server accepted the connection | Something is listening and every layer allows it |
| Closed | The server replied straight away with a refusal | The machine is reachable, but nothing listens on that port, or a firewall actively rejects it |
| Filtered | No reply at all, so the attempt timed out | A firewall is dropping the traffic, or the address is wrong |
That difference between a fast refusal and a slow timeout is the most useful clue you have. A refusal comes from the server itself, so you know the network path works. A timeout means your packets went somewhere and nothing answered.
Check from outside first
Always test from a different machine and a different network to the server. A check run on the server against its own address often succeeds even when the outside world is blocked, because the traffic never leaves the machine.
Your own laptop on your home or office connection is usually the right place. A second server elsewhere is even better, because it rules out anything odd about your local network.
Linux and macOS: nc
The nc (netcat) command opens a connection and reports the result. On macOS and Ubuntu it is normally installed already.
nc -zv -w 5 example.com 443
-z tells it to connect and close without sending data, -v prints the result and -w 5 gives up after five seconds. A success on Ubuntu looks like this:
Connection to example.com 443 port [tcp/https] succeeded!
If nc is missing, install it. On Ubuntu and Debian:
sudo apt install netcat-openbsd
On AlmaLinux and Rocky Linux the package is Ncat, which the nc command then runs:
sudo dnf install nmap-ncat
Ncat prints a slightly different message, such as Ncat: Connected to 203.0.113.10:443., but means the same thing.
Windows: Test-NetConnection
Windows has a built-in check in PowerShell:
Test-NetConnection example.com -Port 443
Look for the last line. TcpTestSucceeded : True means the port is open. False comes with a warning that the TCP connect failed; the command does not say whether it was refused or timed out, so if you need that detail, try nc from Git Bash or WSL, or curl as below.
Any system: curl
curl is installed on current Windows, macOS and most Linux systems. For a web port, ask for the page and watch the first lines:
curl -v https://example.com
For any other TCP port, curl can make a bare connection:
curl -v telnet://example.com:25
A line containing Connected to means the port is open; press Ctrl+C to leave. Connection refused and Connection timed out mean what they do in the table above.
Checking several ports: nmap
Nmap is a free network scanner that checks many ports at once and uses the same open, closed and filtered words as the table. Install it with sudo apt install nmap or sudo dnf install nmap, or from the Nmap website on Windows and macOS, then name the ports you care about:
nmap -p 22,80,443 example.com
Only scan machines you own or have permission to test. Checking a single port on your own server is routine. Scanning other people’s networks can break their terms of service or the law, and hosts may suspend accounts that do it.
Online port checkers
A web-based port checker connects from its own servers, which makes it a genuine outside test. It is handy when you want to know whether a home server or a small project is reachable from the internet. Most only test TCP. Some let you enter any address, while others only test the public address you are visiting from, which suits a home connection but not a server elsewhere. Treat a single result with care: some checkers time out quickly and report “closed” for what is really “filtered”.
Then check on the server
If the outside check fails, log in to the server over SSH and work through the layers from the inside out.
Is anything listening?
sudo ss -tlnp
-t shows TCP, -l shows listening sockets, -n shows numbers instead of names and -p shows the program (which needs sudo). Use -ulnp for UDP. Typical output, trimmed:
State Local Address:Port Process
LISTEN 0.0.0.0:22 users:(("sshd",pid=812))
LISTEN 0.0.0.0:80 users:(("nginx",pid=1044))
LISTEN 127.0.0.1:3306 users:(("mariadbd",pid=930))
LISTEN [::]:443 users:(("nginx",pid=1044))
If your port is not in the list at all, the problem is the program, not the network. Start it, for example sudo systemctl start nginx, and read sudo systemctl status nginx if it will not stay running.
Is it listening on the right address?
The address before the colon matters as much as the port:
| Local address | Who can connect |
|---|---|
0.0.0.0 or * | Anyone, on every IPv4 address the server has |
[::] | Anyone over IPv6, and on most Linux systems IPv4 too |
127.0.0.1 or [::1] | Only programs on the server itself |
One specific address, such as 203.0.113.10 | Only connections to that address |
In the example, MariaDB on 127.0.0.1:3306 cannot be reached from outside, which is exactly what you want for a database. If a service you do want to reach shows 127.0.0.1, change its listen or bind setting in its configuration file and restart it.
You can also test locally to separate the program from the firewall:
nc -zv 127.0.0.1 80
If this works but the outside check fails, the program is fine and something in the path is blocking it.
Is the server firewall allowing it?
On Ubuntu and Debian with UFW:
sudo ufw status verbose
On AlmaLinux and Rocky Linux with firewalld:
sudo firewall-cmd --list-all
If the port is not allowed, add it as shown in the Linux firewall guide linked below. Remember that 443/tcp and 443/udp are separate rules.
Is a firewall in front of the server?
Many cloud and VPSVPS A private slice of a powerful server, with its own guaranteed share of memory and processing and full control, at a fraction of the price of a whole machine. More about VPS → providers run a network firewall, often called a security group or cloud firewall, outside the server. It is set in the provider’s control panel, and the server cannot see it. When the service listens on 0.0.0.0 and the local firewall allows the port, yet outside checks still time out, this outer firewall is the most likely cause.
Ports that are blocked on purpose
Some failures are not your server at all.
- Port 25 for outgoing mail. Many home internet providers and cloud providers block outbound connections to port 25 to stop spam. A check to another mail server’s port 25 from such a network times out even though that server is fine. Mail apps should send on 587 or 465 instead; see the common ports list linked below.
- Servers at home. A computer on your home network has a private address behind your router. For the internet to reach it, the router needs a port forwarding rule, and some providers share one public address between many customers, in which case port forwarding cannot work at all.
- Office and public Wi-Fi. Corporate and guest networks often allow only web ports outbound. Test from somewhere else before blaming the server.
UDP ports are harder to check. UDP has no connection to accept, so an open UDP port often looks the same as a filtered one. Test a UDP service with its own tool instead, for example a DNSDNS The internet’s phone book. It turns a name people can remember, like example.com, into the number address computers use to find the server. More about DNS → query with dig for port 53.
Common problems
| Symptom | Cause | Fix |
|---|---|---|
| “Connection refused” straight away | Nothing listens on that port, or it listens only on 127.0.0.1 | Start the service and check its address with sudo ss -tlnp |
| Check times out after several seconds | A firewall drops the traffic | Allow the port in UFW or firewalld, then in the provider’s cloud firewall |
| “No route to host” on AlmaLinux or Rocky | firewalld rejects ports that are not allowed with this message | Add the port with firewall-cmd --permanent and reload |
| Works on the server, fails from outside | Local test never leaves the machine | Always test from another network |
| Works by IPv4, fails by IPv6 | Service or firewall rule covers only one | Listen on [::] too and add the IPv6 rule; check the AAAA record |
| Port 25 times out from your laptop | Your provider blocks outbound port 25 | Test from a server, use 587 for sending |
| Browser shows a refused error but port checks pass | Wrong IP in DNS or a cached old address | Compare the address the checker used with your DNS records |
If a browser reports the problem, how to fix ERR_CONNECTION_REFUSED walks through the web serverWeb server The program that answers visitors’ browsers and sends them your website. Also used for the computer it runs on. More about Web server → side in more detail.
Official documentation
Related
- What is a port number? explains ports, TCP and UDP from the ground up.
- Common network ports and what they are used for lists which ports should face the internet.
- How to set up a firewall on Linux shows how to open and close ports safely.
- How to check your IP address in Linux helps you find the address to test.
Something out of date? Software changes. If a step no longer works, tell us and we will check it and update the page.


