My IP Ports
SYSADMIN & DEVOPS NETWORKING

How to Check Open Ports Using CMD & PowerShell (Windows 11 & Linux)

Master the exact command-line workflows to discover listening TCP/UDP sockets, map active ports to background process IDs (PIDs), test socket reachability, and create defensive firewall rules on Windows 11 and modern Linux servers.

7 min read • Platforms: Windows 11 / 10 / Server, Ubuntu, Debian, RHEL • Updated 2026
01

Check Open Ports in Windows Command Prompt (CMD)

The classic netstat (Network Statistics) utility is universally baked into every version of Windows without requiring administrative scripts or PowerShell modules.

List All Active Listening Ports with PIDs

The -a flag displays all connections/listening ports, -n displays numerical IP addresses rather than slow reverse DNS names, and -o displays the owning Process ID (PID).

Command Prompt (Admin) cmd
netstat -ano | findstr LISTENING

Filter by a Specific Port (e.g., Port 80, 443, or 25565)

Search specific port binding cmd
netstat -ano | findstr :25565

Find the Application Name from the Process ID (PID)

The last number on the right in netstat output is the PID. Use tasklist to discover which executable (e.g., java.exe, node.exe, nginx.exe) owns that PID:

Map PID to Process Name (replace 14220 with your PID) cmd
tasklist | findstr 14220
02

Check Open Ports in Modern Windows PowerShell

PowerShell offers object-oriented native cmdlets that provide clean structured data rather than unstructured plain text streams.

View Listening Ports Mapped Directly to Process Names

Run this single command in PowerShell 5.1 / 7+ to get an instant tabular view of the Local Address, Port, PID, and executable Process Name:

PowerShell One-Liner (Listening Sockets + App Names) powershell
Get-NetTCPConnection -State Listen | Select-Object LocalAddress, LocalPort, OwningProcess, @{Name='ProcessName';Expression={(Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName}} | Format-Table -AutoSize

Check if a Specific Port is Currently Bound

Verify port 25565 binding state powershell
Get-NetTCPConnection -LocalPort 25565 -ErrorAction SilentlyContinue
03

Test Socket Reachability with Test-NetConnection

In earlier Windows releases, administrators had to enable optional Telnet clients. In Windows 11/10, Test-NetConnection (alias tnc) conducts a real three-way TCP handshake to test any internal or external socket:

Test Local Port (Verify Daemon Accepts Connections)

Test localhost connection powershell
Test-NetConnection -ComputerName 127.0.0.1 -Port 25565

Look for TcpTestSucceeded : True in the output. If it returns False, your service is stopped or crashed.

Test Remote Server or Router WAN IP

Test external server port powershell
Test-NetConnection -ComputerName example.com -Port 443
04

Linux Equivalents: ss, lsof & nc (netcat)

On Linux servers (Ubuntu, Debian, CentOS, AlmaLinux), netstat has been deprecated in favor of ss (Socket Statistics) because ss reads directly from kernel /proc/net without process iteration lag.

1. Fast Kernel Socket Inspection with `ss`

-t (TCP), -u (UDP), -l (Listening only), -p (Show process/PID), -n (Numeric ports):

Linux ss command bash
sudo ss -tulpn | grep LISTEN

2. Find Process by Port with `lsof`

Inspect specific port with lsof bash
sudo lsof -i :25565

3. Test Outbound TCP Port Reachability with Netcat (`nc`)

Netcat TCP probe (-z zero-I/O, -v verbose) bash
nc -zv 127.0.0.1 25565
05

How to Allow Inbound Ports in Windows Firewall

Even after configuring router port forwarding, Windows Defender Firewall will reject unsolicited inbound packets by default. You can open specific ports safely via PowerShell Administrator:

Create an Inbound Allow Rule for TCP (e.g., Port 25565)

PowerShell (Run as Administrator) powershell
New-NetFirewallRule -DisplayName 'Allow Port 25565' -Direction Inbound -LocalPort 25565 -Protocol TCP -Action Allow

Linux ufw Equivalent (Ubuntu/Debian)

UFW Firewall rule bash
sudo ufw allow 25565/tcp && sudo ufw reload
06

Troubleshooting Common Socket & Firewall Errors

Symptom / Error Underlying Cause Actionable Resolution
Socket CLOSED / ECONNREFUSED Server is bound to 127.0.0.1 or service process stopped. Change listen host in server config to 0.0.0.0. Restart daemon.
Timeout / FILTERED Firewall dropped packet or router forwarding rule missing. Add inbound firewall allow rule; check router WAN forwarding and CGNAT.
EADDRINUSE (Address already in use) Another process is already bound to that port. Find PID with Get-NetTCPConnection, then terminate with Stop-Process -Id <PID>.

Ready to verify external reachability?

Test whether your forwarded ports can be accessed from the public internet using our edge TCP engine.

Test on onmyport.com