How do I find out which process is listening on a TCP or UDP port on Windows?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
On Windows, finding which process is using a specific port is a two-step operation: find the port to get the owning PID, then map that PID to a process name. You can do this with built-in command-line tools (netstat, tasklist), PowerShell cmdlets (Get-NetTCPConnection, Get-NetUDPEndpoint), or graphical utilities like Resource Monitor and Sysinternals TCPView.
The most common scenario is a "port already in use" error when starting a development server, and the steps below resolve it in under a minute.
Method 1: Command Prompt with netstat and tasklist
The most portable approach uses netstat, which is available on every Windows version. To find what is listening on TCP port 8080:
Typical output:
The flags explained:
| Flag | Meaning |
-a | Show all connections and listening ports |
-o | Show the owning PID for each connection |
-n | Show addresses and ports numerically (no DNS lookups) |
-p tcp | Filter to TCP protocol only |
The last column (12456) is the PID. To find the process name:
Output:
Now you know node.exe (PID 12456) is listening on port 8080.
One-Liner Approach
For a faster workflow, chain the commands:
This extracts the PID from netstat output and passes it directly to tasklist. In a batch file, double the % signs:
Method 2: PowerShell (Recommended for Scripting)
PowerShell provides structured objects instead of text parsing, making it more reliable for automation.
Finding a TCP Port Owner
Sample output:
Finding a UDP Port Owner
UDP is connectionless, so there is no LISTENING state. Instead, query bound endpoints:
Scanning All Listening Ports
To see every listening port and its owner:
Killing the Process from PowerShell
Once you have the PID, you can stop the process directly:
Or as a combined one-liner:
Be cautious with this, especially on production systems. Always confirm the process name before killing it.
Method 3: Graphical Tools
Resource Monitor (Built-in)
- Press
Win + R, typeresmon, and press Enter - Navigate to the Network tab
- Expand the Listening Ports section
- Find your port number and read the associated image name and PID
Resource Monitor also shows network activity per process, which is useful when you need more context than just the port binding.
TCPView (Sysinternals)
TCPView from Microsoft's Sysinternals suite provides a live, sortable view of all TCP and UDP endpoints on the system. It updates in real time and lets you close connections or kill processes from the UI.
Download it from the Sysinternals website or install it via winget:
TCPView is particularly useful when you are investigating port conflicts interactively, since you can sort by port number and immediately see all owners.
Handling svchost.exe Results
Sometimes the process that owns the port is svchost.exe, which is a generic host for Windows services. Multiple services can run inside a single svchost.exe instance, so the PID alone does not tell you which service is responsible.
To identify the specific service:
Or from the command prompt:
This lists the Windows services hosted by that PID. Common examples include:
| Port | Service | Description |
| 80 | W3SVC | IIS Web Server |
| 135 | RpcSs | RPC Endpoint Mapper |
| 445 | LanmanServer | SMB File Sharing |
| 5040 | CDPSvc | Connected Devices Platform |
TCP vs UDP: Key Differences in Output
| Aspect | TCP | UDP |
Shows LISTENING state | Yes | No (UDP is connectionless) |
netstat flag | -p tcp | -p udp |
| PowerShell cmdlet | Get-NetTCPConnection | Get-NetUDPEndpoint |
| State filtering | -State Listen | Not applicable |
| Common ports | 80, 443, 8080, 3306 | 53 (DNS), 5353 (mDNS), 67 (DHCP) |
The absence of LISTENING in UDP output does not mean the port is unused. It means UDP does not have a connection state. If netstat shows a UDP row with your port number, something is bound to it.
Administrator Privileges
Some system processes and services require elevated privileges to inspect. If your output seems incomplete or the PID column shows 0 or blank values:
In PowerShell, launch an elevated session:
Running as Administrator is not always necessary, but it prevents false negatives that can waste significant debugging time.
Quick Reference: Common Scenarios
Common Pitfalls
Forgetting the -o flag in netstat removes the PID column from the output, making it impossible to identify the process. Always include -o.
Searching for :80 without anchoring matches :8080, :8000, :80 and other ports that contain the sequence 80. Use findstr " :80 " with spaces or findstr /R ":80[^0-9]" for more precise matching.
Expecting UDP ports to show LISTENING leads to the wrong conclusion that the port is free. UDP is stateless, so the bound port shows without any state label.
Stopping at svchost.exe without investigating the underlying service leaves you without actionable information. Use tasklist /SVC or Get-WmiObject Win32_Service to dig deeper.
Running without Administrator privileges can hide system-owned ports. If your results look incomplete, rerun the command in an elevated prompt.
Confusing netstat syntax across operating systems causes errors. On Linux, netstat uses -tulpn, while on Windows it uses -aon -p tcp. The flags are not interchangeable.
Summary
- The standard Windows workflow is: find the port (get the PID), then map the PID to a process name.
- '
netstat -aonwithfindstrandtasklistworks on every Windows version.' - PowerShell cmdlets (
Get-NetTCPConnection,Get-NetUDPEndpoint) return structured objects and are better for scripting. - TCP shows
LISTENINGstate; UDP does not, but the port is still in use if it appears in the output. - If the result is
svchost.exe, investigate the specific Windows service running inside it. - Run as Administrator when results seem incomplete or the system port range is involved.
- Use Resource Monitor or TCPView for interactive investigation.

