Kill Whatever Is Holding a Port on Windows

Find the process listening on a TCP port with Get-NetTCPConnection, then stop it with Stop-Process.

WindowsProcessesnetworksystempowershellMedium risk
Run `Get-NetTCPConnection -LocalPort 8080 | Select-Object LocalPort, State, OwningProcess` to get the PID, then `Stop-Process -Id <pid>` to end it.

01Command

Command
$ Get-NetTCPConnection -LocalPort 8080 | Select-Object LocalPort, State, OwningProcess    ::  then:  Stop-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess

02What it does

When a dev server or old app refuses to release port 8080 (or any other port), Get-NetTCPConnection shows every connection on it, and the OwningProcess column contains the PID holding it. Stop-Process then terminates that PID directly, freeing the port. Add -Force for processes that resist a normal stop.

03Risk

RiskMedium risk
RequirementsUse an elevated (Administrator) PowerShell to inspect or stop processes you don't own.
!Warning: Check which process you're killing first — stopping a system or database service can break other applications that depend on it.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Get-NetTCPConnection
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents -LocalPort as a filter parameter and the OwningProcess property of returned NetTCPConnection objects (the PID of the process that owns the connection).
  • Stop-Process — Stop a running process
    SS64 · technical · 2026-09-17
    Evidence: Syntax shows Stop-Process -id <Int32[]> (and -Name/-Force) for terminating processes by process id.

Last verified: 2026-09-19 · Category: System & Settings

06Related solutions