Whether you’re troubleshooting network issues, setting up a server, or ensuring security compliance, check port state is an essential task for system administrators and developers alike. Ports are communication endpoints for networked devices, and knowing which ones are open can help you monitor traffic, detect vulnerabilities, or verify that services are running properly.
In this article, we’ll walk you through how to check open ports on both Windows and Linux systems. No matter your operating system or level of experience, these steps will equip you with the tools needed to manage and secure your network more effectively.
Check listening ports in Windows
To check listening ports in Windows, you can use several built-in tools. Here’s how:
Method 1: Using netstat
Command
- Open Command Prompt as Administrator:
PressWin + X
→ choose Command Prompt (Admin) or Windows Terminal (Admin).
- Run the following command:
netstat -ano | findstr LISTENING
- To find which program is using a specific port:
tasklist /FI "PID eq <PID_NUMBER>"
Method 2: Using PowerShell
Run this command in PowerShell:
Get-NetTCPConnection -State Listen
You can also filter by port or local address:
Get-NetTCPConnection -State Listen | Where-Object { $_.LocalPort -eq 80 }
Method 3: Using Resource Monitor
- Press
Win + R
, typeresmon
, and press Enter.
- Go to the Network tab.
- Under Listening Ports, you can see:
- The port number
- The process name
- The PID
Check listening ports in Linux
To check listening ports in Linux, you can use various command-line tools depending on what’s installed. Here’s a list of the most common and effective methods:
Method 1: Using ss
(modern and preferred)
ss -tuln
-t
: TCP ports-u
: UDP ports-l
: Listening ports only-n
: Show numeric port numbers (skip DNS lookup)
To include the process using the port:
ss -tulnp
Method 2: Using netstat
(older but still common)
Note:
netstat
may require installingnet-tools
on some systems.
netstat -tuln
- Add
-p
to show the program name and PID:
netstat -tulnp
Method 3: Using lsof
sudo lsof -i -P -n | grep LISTEN
-i
: Network files-P
: Show port numbers instead of service names-n
: Do not resolve hostnamesgrep LISTEN
: Filters for listening ports only
Check remote ports in Windows
To check if a remote port is open in Windows, you can use several built-in tools or third-party utilities. Here are the most effective methods.
Method 1: Using Test-NetConnection
in PowerShell (Recommended)
This is the most modern and reliable method:
Test-NetConnection -ComputerName <hostname_or_ip> -Port <port_number>
Example:
Test-NetConnection -ComputerName example.com -Port 80
- Shows if the port is reachable
- Provides ping status, TCP connection, and more
Method 2: Using Portqry
Tool from Microsoft
Download from Microsoft: PortQry Command Line Port Scanner
Basic usage:
portqry -n <hostname_or_ip> -p tcp -e <port_number>
Example:
portqry -n 192.168.1.100 -p tcp -e 3389
Gives detailed results like:
- Listening
- Not listening
- Filtered
Check remote ports in Linux
To check if a remote port is open in Linux, you can use several command-line tools depending on what’s available on your system. Below are the most common and effective methods.
Method 1: Using nc
(Netcat) for check port
nc -zv <hostname_or_ip> <port>
-z
: Zero-I/O mode (scan without sending data)-v
: Verbose output
Example:
nc -zv example.com 443
✅ If the port is open, it will return:Connection to example.com 443 port [tcp/https] succeeded!
❌ If closed, you’ll see a connection refused or timed out message.
Method 2: Using nmap
(Advanced and powerful)
nmap -p <port> <hostname_or_ip>
Example:
nmap -p 22 192.168.1.1
You can scan multiple ports or ranges:
map -p 22,80,443 example.com
Or scan all 65,535 TCP ports:
nmap -p- example.com
Method 3: Using timeout
with bash
built-ins (No extra tools)
timeout 3 bash -c "</dev/tcp/<hostname_or_ip>/<port>" && echo "Open" || echo "Closed"
Example:
timeout 3 bash -c "</dev/tcp/example.com/22" && echo "Open" || echo "Closed"
Conclusion
Being able to check port state —both locally and remotely—is a fundamental skill for anyone managing systems or troubleshooting network issues. Whether you’re using Windows or Linux, there are reliable built-in tools and optional utilities that allow you to verify which ports are listening and whether a remote service is reachable.
On the local side, commands like netstat
, ss
, and lsof
help identify active ports and their associated processes. For remote checks, tools such as Test-NetConnection
, nc
, and nmap
make it easy to test connectivity and detect potential firewalls or configuration issues.
By mastering these methods, you can better secure your systems, ensure services are functioning correctly, and quickly diagnose connection problems. Whether you’re working on a personal project or maintaining enterprise infrastructure, these port-checking techniques are essential parts of your network toolbox.