killport
Tiny killport <port> shortcut for Windows, from Git Bash or PowerShell.
Two snippets – one Bash, one PowerShell – exposing a killport <port> function. It finds the PID LISTENING on the given TCP port and terminates it, printing the PID or no LISTENING process on port <n> if nothing was bound.
The Bash version pipes netstat -ano through grep LISTENING and awk into taskkill //PID <pid> //F. The PowerShell version takes Get-NetTCPConnection -LocalPort $Port -State Listen into Stop-Process -Force. Both filter on LISTENING only – TIME_WAIT and ESTABLISHED sockets are ignored, so an open client connection to the same port doesn’t get swept up with the server.
It exists because the usual Windows recipe – netstat, copy PID, taskkill – is two steps too many when a dev server is stuck on 5173 and you just want it gone.
Writeups
from this project