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.
01Command
$ Get-NetTCPConnection -LocalPort 8080 | Select-Object LocalPort, State, OwningProcess :: then: Stop-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess02What 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
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Get-NetTCPConnectionEvidence: 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 processEvidence: 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
The nuclear option for broken connectivity: rebuild Winsock and the TCP/IP stack to defaults when adapters show 'no internet' despite everything else working.
Register a recurring Windows task entirely from the command line — ideal for scripts, cleanup jobs, and monitoring probes you want to run unattended.
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.