Find and Kill a Process on a Specific Port on Windows

November 30, 2025

windows

TLDR

bash
1.netstat -ano | findstr :<PortNumber>
2.
3.taskkill /PID <PID> /F

Find what is running on a port using Command Prompt

Open Command Prompt and run netstat -ano piped to findstr with your port number to find the process ID (PID) of whatever is using that port.

bash
1.netstat -ano | findstr :<PortNumber>

Example

bash
1.> netstat -ano | findstr :8000
2.
3. TCP 127.0.0.1:8000 0.0.0.0:0 LISTENING 24922
4. TCP [::1]:8000 [::]:0 LISTENING 24922

The last column is the PID (Process ID). In this example, the PID is 24922.

Kill the process using Command Prompt

Use taskkill with the /PID flag and /F to forcefully terminate the process.

bash
1.taskkill /PID <PID> /F

Example

bash
1.> taskkill /PID 24922 /F
2.
3.SUCCESS: The process with PID 24922 has been terminated.

PowerShell Method

If you prefer PowerShell, you can use Get-NetTCPConnection to find the process and Stop-Process to kill it.

Find the process

powershell
1.Get-NetTCPConnection -LocalPort <PortNumber>

Example

powershell
1.> Get-NetTCPConnection -LocalPort 8000
2.
3.LocalAddress LocalPort RemoteAddress RemotePort State OwningProcess
4.------------ --------- ------------- ---------- ----- -------------
5.127.0.0.1 8000 0.0.0.0 0 Listen 24922

The OwningProcess column shows the PID.

Kill the process

powershell
1.Stop-Process -Id <PID> -Force

Example

powershell
1.Stop-Process -Id 24922 -Force

One-liner to find and kill in PowerShell

You can combine both commands into a single line that finds and kills the process on a specific port:

powershell
1.Stop-Process -Id (Get-NetTCPConnection -LocalPort 8000).OwningProcess -Force

Found this helpful? Follow for more tips and tutorials