Find which process is listening on a TCP or UDP port on Windows
Codemia Knowledge Hub ·
Run netstat -aon filtered with findstr to get the PID that owns the port, then look up that PID with tasklist. PowerShell's Get-NetTCPConnection and Get-NetUDPEndpoint do the same with structured output, and Resource Monitor or Sysinternals TCPView show it graphically. This is the quickest fix for a "port already in use" error when starting a development server.
netstat and tasklist in Command Prompt
netstat is available on every Windows version. To find what is listening on TCP port 8080:
Typical output:
| 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 over IPv4 only (use -p tcpv6 for IPv6) |
Without -o there is no PID column, so always include it. The last column (12456) is the PID. Look up the process name:
Output:
So node.exe (PID 12456) is listening on port 8080.
One-liner
Chain the two commands to pass the PID straight to tasklist:
In a batch file, double the % signs:
Matching the exact port with findstr
Searching for :80 also matches :8080, :8000 and any other port containing 80. Use findstr " :80 " with spaces or findstr /R ":80[^0-9]" for more precise matching.
PowerShell cmdlets (better for scripting)
PowerShell returns objects instead of text, so there is nothing to parse.
TCP port owner
Sample output:
UDP port owner
UDP is connectionless and has no LISTENING state, so query bound endpoints instead:
All listening ports
Stopping the process
Once you have the PID:
Or in one line:
Be careful with this, especially on production systems, and confirm the process name before killing it.
Resource Monitor and TCPView
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 helps when you need more context than the port binding.
TCPView (Sysinternals)
TCPView from Microsoft's Sysinternals suite gives a live, sortable view of all TCP and UDP endpoints. It updates in real time and can close connections or kill processes from the UI. Download it from the Sysinternals website or install it with winget:
Sorting by port number shows every owner at once, which makes it handy for investigating conflicts interactively.
When the owner is svchost.exe
svchost.exe is a generic host for Windows services, and one instance can run several services, so the PID alone does not identify the culprit. List the services in that process:
Or from Command Prompt:
Common examples:
| 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 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) |
A UDP row without LISTENING does not mean the port is free. UDP has no connection state, so if netstat shows a UDP row with your port, something is bound to it.
Running as Administrator
Some system processes and services can only be inspected with elevated privileges. If output looks incomplete, or the PID column shows 0 or blanks, rerun from an elevated Command Prompt (right-click CMD, then Run as administrator):
In PowerShell, start an elevated session:
Elevation is not always needed, but it avoids false negatives that waste debugging time.
Quick reference
Note that the flags differ from Linux, where netstat uses -tulpn. On Windows use -aon -p tcp; the two are not interchangeable.
Related reading
- Kafka: Consumer API vs Streams API
- What exactly is RESTful programming?
- A3C in Tensorflow - Should I use threading or the distributed Tensorflow API
- A clean, lightweight alternative to Python''s twisted?
- A single threaded client/server in C# with file upload, download
- Accent detection API?
- AcceptTcpClient and AcceptTcpClientAsync difference
- Access host database from a docker container
System design interview problems on this topic
- Design a Load Balancer: solution and walkthrough
- Design a Domain Name System: solution and walkthrough
- Design a Global Content Distribution Network: solution and walkthrough
- Design an API Rate Limiter: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.