To check open ports on your own machine, use netstat -ano or Get-NetTCPConnection on Windows, sudo ss -tulnp on Linux, and sudo lsof -i -P on macOS. To check whether a port is reachable from outside, scan it from another machine with nmap -p 22,80,443 target, or test a single port with nc -zv host port on Linux and Test-NetConnection host -Port port on Windows. Only scan systems you own or have permission to test.
Key takeaways
- Local tools show what is listening; a remote scan shows what is actually reachable from outside.
- On Windows use netstat -ano, on Linux sudo ss -tulnp, on macOS sudo lsof -i -P.
- An open port is only a risk if the program behind it is unnecessary, unpatched or exposed to the internet.
Every open port is a door into your machine — and most computers have more doors open than their owners realize. A quick check takes two minutes, and it is one of the highest-value security habits you can build. Here is how to list every open port on Windows, Linux and macOS, find out which program opened each one, and close the doors that should not be there.
What does it mean for a port to be open?
A port is open when a program on your machine is listening on it and accepting connections. Your browser connects to port 443 on a web server; a game server listens on its own port; remote desktop listens on port 3389. An open port is not automatically bad — it is how services work.
The risk depends on what is behind the door. A patched web server on a port you intended to open is fine. An old, unpatched service listening on the internet is an invitation. The goal of checking is not to close everything, but to know exactly what is listening and why.
There are two different questions here, and they need different tools. "What is listening on my machine?" is answered locally with netstat, ss or lsof. "What can the outside world reach?" is answered from another machine with nmap or an online scanner. Do both.
What do open, closed and filtered mean?
Nmap, the standard port scanner, classifies each port by how it responds. Understanding the three main states saves a lot of confusion when you read scan results.
| State | Meaning | What to do |
|---|---|---|
| Open | A service is accepting connections on this port | Check which program it is; close it if you do not need it |
| Closed | The host is reachable but nothing listens here | Nothing to do — this is the normal state for unused ports |
| Filtered | A firewall blocks probes, so the scanner cannot tell | Confirm the firewall rule is intentional, not an accident |
| Unfiltered | The port is reachable but nmap cannot tell if it is open | Re-scan with a different technique to get a clear answer |
Filtered is usually good news — it means your firewall is doing its job. But a filtered port you expected to be open means a firewall rule is blocking something you need, so check your rules.
How do I check open ports on Windows?
Windows has everything built in. The quickest check is netstat, and PowerShell gives a cleaner, filterable view when you want more detail.
Using netstat
Open a command prompt and run netstat -ano | findstr LISTENING. The -a shows all connections and listening ports, -n keeps them numeric, and -o adds the owning process ID, which you can match in Task Manager. To check one port, use netstat -ano | findstr :3389.
Using PowerShell
PowerShell's native equivalent is Get-NetTCPConnection -State Listen. It returns structured output you can sort and filter, for example Get-NetTCPConnection -State Listen | Sort-Object LocalPort. To ask about a single port, run Get-NetTCPConnection -LocalPort 8080 -State Listen.
To map a process ID to a program name, run tasklist /FI "PID eq 1234", replacing 1234 with the ID from netstat. On Windows you will commonly see port 135 for RPC and ports 139 and 445 for SMB.
You may also see port 3389 for remote desktop and port 5985 for WinRM. If you do not use remote desktop, 3389 should not be listening — and it should never be exposed to the internet. DarazHost's port-checking guide shows the same commands with example output for each platform.
How do I check open ports on Linux?
On Linux the modern tool is ss, short for socket statistics. It is faster than the older netstat and is preinstalled on most distributions. Run sudo ss -tulnp to list all listening TCP and UDP ports with the process that owns each one.
The flags read as tcp, udp, listening, numeric and process. You need sudo to see process names for other users' processes. To check one port, run sudo ss -tlnp 'sport = :443'. The older sudo netstat -tulnp produces the same output where net-tools is still installed.
For a single port, sudo lsof -i :22 shows exactly what holds port 22, and sudo lsof -p 1234 shows everything one process has open. ProtocolPorts' guide to checking open ports walks through the same commands with worked examples for all three operating systems.
How do I check open ports on macOS?
macOS ships with lsof and netstat but not ss, so lsof is the most reliable option. Run sudo lsof -i -P -n | grep LISTEN to see all listening sockets with process names and numeric ports.
To check one port, run sudo lsof -i :5900 -P -n. The classic netstat -an | grep LISTEN also works, but macOS netstat does not show process IDs, so prefer lsof when you need to know which program owns a port.
How do I check if a port is open remotely?
Local tools only show what one machine believes it is listening on. To learn what is actually reachable, probe from elsewhere. Pick the tool that matches the question you are asking.
Netcat: the fast one-liner
For a single port, netcat is fastest: nc -zv example.com 443. The -z scans without sending data and -v makes it report the result. A success means the port is open; a refusal means it is closed; a timeout usually means a firewall is filtering it.
Test-NetConnection: the Windows-native check
Windows PowerShell includes a built-in remote test, so you need nothing extra: Test-NetConnection example.com -Port 443. It returns a clear True or False, plus the round-trip time.
Nmap: ranges and service detection
For more than one port, nmap is the standard tool. Check specific ports with nmap -p 22,80,443 example.com, scan a range with nmap -p 1-1024 example.com, and add -sV to fingerprint the service and version behind each open port. Nmap also has a graphical front end called Zenmap if you prefer not to use the command line.
Curl and telnet: no-install options
You can test a port with tools you already have. curl -v telnet://example.com:443 tries to connect and reports the result, and Bash can test TCP directly with timeout 3 bash -c 'cat < /dev/null > /dev/tcp/example.com/443' && echo open. Telnet works too — telnet example.com 443 — but on Windows it is an optional feature you must enable first.
Which ports should you expect to see open?
A short list of common ports helps you recognize normal listeners and spot odd ones. If a port is open and you cannot explain it, investigate before ignoring it.
| Port | Service | Normal to see open? |
|---|---|---|
| 22 | SSH | Yes, on servers you manage remotely |
| 80 | HTTP | Yes, on a web server |
| 443 | HTTPS | Yes, on a web server |
| 25, 587 | SMTP mail | Yes, on a mail server |
| 53 | DNS | Yes, on a DNS server or router |
| 3306 | MySQL | Only on a database server, and not to the internet |
| 3389 | Remote Desktop (RDP) | Only if you use it, and never exposed publicly |
| 23 | Telnet | Almost never — unencrypted and unsafe |
| 445 | SMB file sharing | On a local network only, never to the internet |
Port 23 is the clearest red flag: Telnet sends everything, including passwords, in plain text. If you find it open, close it and use SSH instead. The same applies to database ports like 3306 — they should listen on localhost or a private network, never on a public address.
How do you close an open port?
Closing a port means stopping the program that opened it, or blocking it at the firewall. The right choice depends on whether you need the service at all.
- Find the owner. Use netstat, ss or lsof to get the process ID, then map it to a program name.
- Decide if you need it. If the program is something you installed and use, keep it but make sure it is updated. If you do not recognize it, investigate before killing it.
- Stop the service if you do not need it: disable it in Services on Windows, or stop it with your system service manager on Linux.
- Block it at the firewall if you need the service locally but not from the network. Windows Firewall and Linux firewalls can block a port while the service keeps running for local use.
- Remove port-forwarding rules on your router for ports you no longer need exposed to the internet.
- Re-scan after the change to confirm the port is closed or filtered.
On a home router, check for Universal Plug and Play (UPnP) rules too: some devices open ports on your router automatically, and you may not know they did. If your router supports it, turn UPnP off and forward ports manually. Our guide to securing your Wi-Fi covers router settings in more detail.
Common mistakes when checking open ports
The most common mistake is checking locally and stopping there. A local list shows what your machine thinks is listening, but a firewall or router rule can mean the internet sees something different. Always confirm with a remote scan.
Other mistakes: scanning someone else's system without permission, and confusing "filtered" with "open". Closing a port by killing a program you actually need is another common error.
If a service stops working after you close a port, check which program owned it before assuming the port was the problem. Remember that UDP ports are harder to check than TCP — a UDP scan can report a port as open when nothing is listening, so confirm UDP results with the owning program.
The bottom line
Checking open ports is a two-minute habit with outsized value: list listeners locally, scan remotely, and close what you cannot explain. Do it after installing new software, after a security scare, and whenever you change router settings.
For a wider view of what the internet can see about your setup, run our free SSL checker on any site you run.
Use the what-is-my-IP tool to confirm the address you are scanning from before you start.
Frequently asked questions
How do I check if a port is open on Windows?
Open a command prompt and run netstat -ano, then look for LISTENING entries, or use PowerShell with Get-NetTCPConnection -State Listen. To test a remote port, run Test-NetConnection example.com -Port 443, which returns True or False.
How do I check open ports on Linux?
Run sudo ss -tulnp to list all listening TCP and UDP ports with the process that owns each one. The older netstat -tulnp gives the same output where it is installed, and lsof -i :22 shows what holds one specific port.
What is the difference between an open, closed and filtered port?
Open means a service is accepting connections. Closed means the host is reachable but nothing is listening on that port. Filtered means a firewall is blocking probes, so the scanner cannot tell whether anything is listening.
Is it illegal to scan ports?
Scanning systems you do not own and have no permission to test can break computer-misuse laws and trigger intrusion-detection alarms. Only scan your own machines, or systems where you have explicit written authorization.
How do I check if a port is open from outside my network?
Scan it from another machine with nmap -p 443 your-host, or use an online port scanner. A local list only shows what your machine believes it is listening on — a remote check shows what the internet can actually reach.
Which ports should be closed?
Close any port whose program you do not need, especially remote-access ports such as 3389 for RDP and 23 for Telnet when exposed to the internet. Common safe listeners on a home PC include 80 and 443 for a local web server only if you run one.
Can I check open ports without installing anything?
Yes. Windows has netstat and PowerShell built in, Linux has ss, and macOS has lsof and netstat. For a single remote port, curl and the Bash built-in /dev/tcp also work without extra tools.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against Nmap documentation and current Windows, Linux and macOS command references.
How we write and fact-check →