To find which ports are in use on Windows, use netstat -ano in Command Prompt, Get-NetTCPConnection and Get-NetUDPEndpoint in PowerShell, or the graphical tools Resource Monitor and TCPView. This guide shows those methods, then explains how to read the output, match a port to its process or service, fix port conflicts and test whether a port can be reached.
How to check for used ports on Windows?
Using Command Prompt
- Netstat: This command displays active connections and listening ports.
- Open Command Prompt (you can search for
cmdin the Start menu). - Type
netstat -anoand press Enter. This will list all ports in use along with the process IDs (PIDs) using them. - To find a specific port, you can use
netstat -ano | findstr "PORT_NUMBER", replacingPORT_NUMBERwith the port you’re interested in.
- Open Command Prompt (you can search for
- TCPView: This is a graphical utility from Sysinternals that provides a more detailed view of TCP and UDP endpoints. You need to download it from Microsoft’s website.
Using PowerShell
- Open PowerShell (you can search for
powershellin the Start menu). - Run the following command:
Get-NetTCPConnection | Where-Object { $_.LocalPort -eq PORT_NUMBER }, replacingPORT_NUMBERwith the port you want to check. - Alternatively, you can use
Get-Process -Id (Get-NetTCPConnection -LocalPort PORT_NUMBER).OwningProcessto get more information about the process that’s using the port.
Using Resource Monitor
- Open Resource Monitor, which can be found by searching in the Start menu or under the “Performance” tab of Task Manager.
- Go to the “Network” tab.
- Look at the “Listening Ports” section to see which ports are in use and by which processes.

Reading netstat output
netstat -ano prints one line per socket. -a shows all connections and listening ports, -n shows numbers instead of host and service names (much faster), and -o adds the owning process ID. A typical result looks like this:
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 1032
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 127.0.0.1:5432 0.0.0.0:0 LISTENING 3920
TCP 192.168.1.20:52144 20.190.151.7:443 ESTABLISHED 8812
TCP [::]:80 [::]:0 LISTENING 4
UDP 0.0.0.0:5353 *:* 2460Code language: CSS (css)
| Value | Meaning |
|---|---|
0.0.0.0:PORT or [::]:PORT | Listening on every IPv4 or IPv6 interface, so other machines can reach it unless the firewall blocks it |
127.0.0.1:PORT | Listening only on loopback, so only the local machine can connect |
LISTENING | A server socket waiting for connections. This is usually what blocks another app from using the port |
ESTABLISHED | An active connection. The local port is often a random high (ephemeral) port |
TIME_WAIT | A recently closed connection. It clears on its own and shows PID 0 |
CLOSE_WAIT | The remote side closed the connection but the local app has not. Many of these usually mean an application bug |
UDP has no connections, so UDP lines have no state. To list one protocol only, use netstat -ano -p TCP or netstat -ano -p UDP.
Corrected port lookup commands
Some commands in the example above give misleading results. findstr "80" matches any line that contains those digits, including ports 8080 and 3380 and PIDs such as 1804. Search for the colon, the port and the space after it instead. /C: makes findstr treat the space as part of the search text rather than a separator:
netstat -ano | findstr /C:":8080 "
rem Only listening sockets on that port
netstat -ano | findstr /C:":8080 " | findstr LISTENINGCode language: JavaScript (javascript)
In PowerShell, filter with parameters instead of piping every connection through Where-Object. Add -State Listen to skip client connections. Add -ErrorAction SilentlyContinue because the cmdlet throws an error when nothing matches. Select-Object -Unique stops the same process appearing once for every connection:
# TCP listener on a port
Get-NetTCPConnection -LocalPort 8080 -State Listen -ErrorAction SilentlyContinue
# Process behind it (safe when nothing is found or many connections exist)
$pids = (Get-NetTCPConnection -LocalPort 8080 -ErrorAction SilentlyContinue).OwningProcess |
Select-Object -Unique
if ($pids) { Get-Process -Id $pids } else { 'Port 8080 is not in use (TCP)' }
# UDP is separate: Get-NetTCPConnection never shows UDP ports
Get-NetUDPEndpoint -LocalPort 53 -ErrorAction SilentlyContinueCode language: PHP (php)
Note: Get-NetTCPConnection and Get-NetUDPEndpoint come from the NetTCPIP module. They are available in Windows PowerShell 5.1 and in PowerShell 7 on Windows, but not on Linux or macOS.
Listing every listening port with its process name
Use this report for a quick audit of a server. It shows every TCP listener and UDP endpoint with the process name, sorted by port:
$tcp = Get-NetTCPConnection -State Listen | ForEach-Object {
[pscustomobject]@{
Proto = 'TCP'
Address = $_.LocalAddress
Port = $_.LocalPort
PID = $_.OwningProcess
Process = (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName
}
}
$udp = Get-NetUDPEndpoint | ForEach-Object {
[pscustomobject]@{
Proto = 'UDP'
Address = $_.LocalAddress
Port = $_.LocalPort
PID = $_.OwningProcess
Process = (Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName
}
}
$tcp + $udp | Sort-Object Proto, Port | Format-Table -AutoSizeCode language: PHP (php)
To save the report or compare it with another server, replace Format-Table -AutoSize with Export-Csv .\ports.csv -NoTypeInformation.
Finding the process, service or command line behind a PID
netstat only gives you a number. The example above does not show how to turn that number into a process in Command Prompt. Use tasklist with a filter:
rem Process name for PID 1032
tasklist /FI "PID eq 1032"
rem Services hosted inside that process (useful for svchost.exe)
tasklist /svc /FI "PID eq 1032"
rem Show the executable name next to each socket (needs an elevated prompt)
netstat -abnoCode language: JavaScript (javascript)
Many Windows services share a single svchost.exe process, so the process name alone is often not enough. In PowerShell you can see the full command line and any services in the process:
Get-CimInstance Win32_Process -Filter "ProcessId = 1032" |
Select-Object ProcessId, Name, ExecutablePath, CommandLine
Get-CimInstance Win32_Service -Filter "ProcessId = 1032" |
Select-Object Name, DisplayName, State, StartModeCode language: JavaScript (javascript)
Note: Run the console as Administrator. Without elevation, netstat -b fails and some processes show no path or command line because you do not have permission to see them.
Common port problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
Port shows PID 4 (System) | The kernel owns it. Usually HTTP.sys (IIS, WinRM, WCF or other apps that reserve URLs), or SMB on 445 | Run netsh http show servicestate to see which app registered the URL, then stop that service (for example W3SVC for IIS) or change its binding |
| App says the port is in use but nothing is listening on it | Windows has reserved the port range, often because of Hyper-V, WSL 2, Docker or WinNAT | Run netsh interface ipv4 show excludedportrange protocol=tcp and choose a port outside the reserved ranges |
Many TIME_WAIT entries with PID 0 | Normal after short connections close | No action needed unless ephemeral ports run out. Reuse connections in the client |
No MSFT_NetTCPConnection objects found | Nothing is using that port | Add -ErrorAction SilentlyContinue or treat the error as "port is free" |
| Port is listening but remote clients cannot connect | It is bound to 127.0.0.1, or Windows Firewall blocks it | Bind to 0.0.0.0 or the server IP, then check the firewall rules (see the next section) |
Freeing a port safely
- Find the PID with
netstat -ano | findstr /C:":8080 "orGet-NetTCPConnection -LocalPort 8080. - Check whether the PID belongs to a service:
tasklist /svc /FI "PID eq <PID>". - If it is a service, stop it properly so it does not just restart:
Stop-Service -Name <ServiceName>. To stop it starting at boot, also runSet-Service -Name <ServiceName> -StartupType Disabled. - If it is an ordinary application, close it normally first. Force it closed only if you must:
Stop-Process -Id <PID>ortaskkill /PID <PID> /F. - Check that the port is free with
Get-NetTCPConnection -LocalPort 8080 -ErrorAction SilentlyContinue. An empty result means nothing is using it.
Note: Do not end PID 4, lsass.exe, wininit.exe or services.exe. Ending these crashes or restarts the system. Stop the service that registered the port instead.
Testing whether a port is reachable
A port can be listening on the server and still be unreachable from other machines. Test from the client side with Test-NetConnection:
Test-NetConnection -ComputerName server01 -Port 443
# Relevant part of the output
# RemoteAddress : 10.0.0.15
# RemotePort : 443
# TcpTestSucceeded : TrueCode language: PHP (php)
If TcpTestSucceeded is False but the server shows the port as LISTENING on 0.0.0.0, check the server's firewall for a rule that allows the port:
Get-NetFirewallPortFilter -Protocol TCP |
Where-Object LocalPort -eq 8080 |
Get-NetFirewallRule |
Select-Object DisplayName, Enabled, Direction, Action, Profile
# Allow the port inbound if no rule exists (elevated prompt)
New-NetFirewallRule -DisplayName 'App 8080' -Direction Inbound -Protocol TCP -LocalPort 8080 -Action AllowCode language: PHP (php)
Note: Only open the ports a service needs, and limit the rule with -RemoteAddress or -Profile Domain where you can. Use the listening-ports report above to find services that are exposed by mistake. More cmdlets are covered in the PowerShell command line reference.
Frequently asked questions
How do I kill the process using a port on Windows?
Find the PID with netstat -ano | findstr /C:":PORT ", then run taskkill /PID <PID> /F or Stop-Process -Id <PID>. If the PID belongs to a service, stop the service with Stop-Service instead, or it may start again.
Why is port 80 or 443 used by PID 4 (System)?
PID 4 is the Windows kernel. A web port held by PID 4 usually means HTTP.sys has registered it for IIS, WinRM or another app that uses HTTP.sys. Run netsh http show servicestate to see which process registered the URL.
Do I need administrator rights to check open ports?
No. netstat -ano and Get-NetTCPConnection work in a normal console. You need an elevated prompt for netstat -b, which shows executable names, and to see details of processes run by other users or SYSTEM.
Why does Windows say a port is in use when netstat shows nothing on it?
Windows may have reserved the port in an excluded range, often for Hyper-V, WSL 2 or Docker networking. Run netsh interface ipv4 show excludedportrange protocol=tcp to see the reserved ranges, and choose a port outside them.
How do I check if a port is open on a remote Windows server?
Run Test-NetConnection -ComputerName <host> -Port <port> from the client and look at TcpTestSucceeded. If it is False, check that the service is listening on a reachable address and that the server's firewall allows the port.
Related tutorials
- Powershell Tutorials: Command Line reference
- Windows Administrator: Role Blueprint, Responsibilities, Skills, KPIs, and Career Path
- More Windows tutorials
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals