How do I find and kill the process holding a port on Windows?
Use PowerShell to identify the PID listening on a Windows port, kill it, and confirm the port is free.
What this covers
Windows blocks the second process that tries to bind the same TCP port, often with “address already in use” or “Only one usage of each socket address is normally permitted.” The fix is to identify the exact PID listening on that port and stop it, then verify the port is free.
Symptom
Find which process is listening on the port
Start here because the PID is what makes the next step safe and precise. Run the listener list, then filter it to the port from the error (for example, 8080 or 3000). The OwningProcess column is the PID you need; note it before moving on. If nothing is listening, the conflict may be from a UDP socket or another user session.
The PowerShell-native replacement for netstat: filter connections by state, port, or process and pipe results instead of parsing text.
$ Get-NetTCPConnection -State Listen | Select-Object LocalAddress, LocalPort, OwningProcessEnd the process by its PID
Use the OwningProcess number from the previous step wherever the command expects <PID>. This kills the process and any children it spawned, which is usually what you want for a dev server or app that left a worker behind. Confirm the PID is the one listening on your port before you force it.
End a process and everything it spawned, using the numeric PID you looked up.
$ taskkill /PID <PID> /T /FHow to confirm it worked
Test the port from the same machine: if nothing answers, the listener is gone. Then restart the app that needed the port.
Sources
- PING - Windows CMDEvidence: SS64 explains ping only tests ICMP echo, which many hosts and firewalls block, unlike a TCP port test.
- Get-NetTCPConnection - PowerShellEvidence: SS64 shows Get-NetTCPConnection usage with -State Listen and -LocalPort filters for listing bound ports.
- Get-NetTCPConnection | Microsoft LearnEvidence: Microsoft documents Get-NetTCPConnection parameters including -State with the Listen value and the OwningProcess property returned for each connection.
- taskkill — Microsoft LearnEvidence: /PID <processid> specifies the process to terminate; /T ends the specified process and any child processes started by it; /F forces termination.
- taskkill — Windows CMD referenceEvidence: TASKKILL /PID pid /T /F terminates the given process and its child processes forcefully.
- Test-NetConnection - PowerShellEvidence: SS64 documents Test-NetConnection's -Port parameter for testing TCP connectivity and the TcpTestSucceeded result property.
Last verified: 2026-09-22
Related guides
App can't connect? Windows Firewall might be blocking it. Learn how to diagnose and fix it with netsh and PowerShell.
A symptom-driven guide to a frozen Windows Update: check update history, repair system files and the component store, reset update components, and install via PowerShell.
A step-by-step problem-fix guide for Windows: identify your disks, rule out failing hardware, find the process or service hammering the disk, optimize the drive, and verify the file system is clean.