If you only need to clear port 3000 from a script, npx kill-port 3000 is free and works on Windows, where it calls TaskKill /F. If you want a CLI that names the service and refuses to kill a database without --force, portrm does that across macOS, Linux, and Windows. If you want to see every listening port with its process and path, kill the right one with a guard against recycled PIDs, and stop the port being taken again, Port Detective is the Windows app built for it. Many developers end up using a CLI in scripts and an app when something is confusing.
This comparison is for Windows developers who hit EADDRINUSE often enough to want a better habit than rebooting.
See who owns the port before you kill it, then keep the port yours with Port Guard.
Get it from Microsoft
What does each tool actually do?
All facts below come from each project’s own page: the kill-port README on GitHub, the portrm site, and the Port Detective product page.
| kill-port | portrm | Port Detective | |
|---|---|---|---|
| Form | npm package and CLI | Rust CLI, TUI, and VS Code extension | Native Windows desktop app (Rust) |
| How you run it | npx kill-port 3000 | npx portrm scan, ptrm fix 3000 | Search a port in the app or tray |
| Platforms | Windows, macOS, Linux (Unix needs lsof) | macOS, Linux, Windows | Windows 10 and 11 |
| Shows what owns the port | No, it kills | Yes, names services such as Next.js, Vite, PostgreSQL, Redis, Docker | Yes: name, PID, full path, parent and child lineage (Pro) |
| Safety before killing | None documented | Blocks system processes, warns on databases, kill blocked without --force | Token-guarded kills against PID reuse; protected OS processes flagged |
| Windows kill method | TaskKill /F | Graceful first, force only if needed (per its site) | Ends the verified owner |
| Ranges and multiple ports | Yes, such as 3000-3005 and 8080,5000 | Preflight checks on several ports | Search any port; remote range scans in Pro |
| Keeps the port free afterward | No | ptrm watch restarts a crashed server | Port Guard (Pro) checks every 250 ms and can end an intruder |
| UDP | --method udp | Not stated | TCP and UDP, IPv4 and IPv6 (Pro) |
| Docker | No | Detects Docker | Maps host ports to container and image (Pro) |
| License or price | MIT, free | Price and license not stated on its home page | Free edition with 5 kills; Pro is a one-time Store purchase |
When is npx kill-port the right choice?
kill-port is the smallest possible answer. The README shows the usage exactly:
npx kill-port 8080
npx kill-port --port 8080,5000,3000
npx kill-port 3000-3005
npx kill-port 9000 --method udp
It shines in package.json scripts, where a predev step clears the port before the dev server starts. It needs Node, which you already have in a JavaScript project, and nothing else on Windows.
What to know before you rely on it:
- It does not tell you what it killed. If port 5432 is your local PostgreSQL rather than a stale server, kill-port ends it anyway.
- On Windows it always forces. The README says “Windows continues to use
TaskKill /Ffor the default or explicitSIGKILL,” and that other Unix signals cannot be delivered through TaskKill. There is no graceful shutdown on Windows. - On Linux and in containers it needs the full lsof. The README warns that BusyBox lsof is not a compatible replacement, and that “No process running on port” does not prove the port is unused.
For a one-port script in a project you control, those limits are fine.
When is portrm the better CLI?
portrm is a newer, more ambitious CLI. Its site describes a “3-Tier Safety System” that “BLOCKS system processes, WARNS about databases with data-loss risk, APPROVES dev servers,” and its demo shows a kill on PostgreSQL blocked until you pass --force. It also does things kill-port does not try to do:
ptrm fix 3000 --run 'npm run dev'clears a port and restarts your server.ptrm doctorlooks for zombie processes, such as a node process stuck in CLOSE_WAIT.ptrm upstarts a whole stack from a.ptrm.tomlfile with preflight port checks.ptrm uiopens a terminal UI, and a VS Code extension adds a sidebar.
If you live in a terminal and want stack orchestration as well as port fixing, portrm is a strong pick and it is cross-platform. Where it is better than Port Detective: it runs on macOS and Linux, it restarts your dev server for you, and it fits in CI.
When is a desktop app better than a CLI?
A CLI answers “free this port.” A lot of Windows port trouble is “why is this port busy, and why does it keep coming back?” That is easier to answer when you can see everything at once:
- The owner is not what you expected. A port held by System (PID 4), a Docker proxy, or a service inside svchost.exe needs a different fix from a stale node.exe. Port Detective shows the full path and flags protected OS processes.
- The PID changed between lookup and kill. Windows reuses process IDs. A plain
taskkill /PIDcan hit a different process if the original exited a moment earlier. Port Detective’s kills are token-guarded, so it only ends the process it showed you. Our post on the PID reuse race explains the problem. - Something keeps grabbing the port. If an updater or another dev server takes 3000 back every few minutes, killing it again does not help. Port Guard in Pro watches the ports you claim every 250 ms, can end the intruder, relaunch your owner, and notify you.
- The port is in a container. Pro maps a host port to the container and image that published it.
One search shows the process, PID, and path behind any port, with guarded one-click kills.
Get it from Microsoft
Can I use them together?
Yes, and that is a sensible setup:
- Keep kill-port or portrm in your scripts for the routine case, where you know exactly what holds the port.
- Open Port Detective when the script fails or the port comes back, to see the real owner and its lineage.
- Claim your important ports with Port Guard (Pro) so your dev server keeps 3000 and 5173.
- Use copy-as-command in Port Detective to paste the exact netstat, taskkill, or PowerShell line into a ticket or a script.
If you want no third-party tool at all, PowerShell can do the lookup and kill in one line:
Get-NetTCPConnection -LocalPort 3000 -State Listen | Select-Object -ExpandProperty OwningProcess | Stop-Process -Confirm
The -Confirm switch makes PowerShell ask before ending the process. Our comparison of stopping a process on a port with PowerShell or a GUI goes deeper.
What does Port Detective cost?
The free edition from the Microsoft Store includes the live port list, instant lookup, process name, PID, and path, and 5 guarded kills. Port Detective Pro is a one-time purchase (US$9.99 regular price in the US Store at the time of writing) that adds unlimited kills, Port Guard, TCP and UDP for IPv4 and IPv6, remote scans, Docker mapping, lineage, connection history export, notes, and a Ctrl+K command palette. It is offline licensed and has no telemetry.
Where Port Detective is the wrong pick: if you are on macOS or Linux, or you need port handling inside CI, use a CLI.
Frequently asked questions
Does npx kill-port work on Windows?
Yes. On Windows it uses TaskKill /F, so the process is force-ended without a graceful shutdown.
Is portrm safe to use on a database port?
Its site says it warns about databases and blocks the kill unless you pass --force. Read what it detected before forcing anything.
Why does my port come back after I kill the process?
Something restarts it: a watcher, a service, or an updater. Find the parent process and stop that, or claim the port with Port Guard. See why a port keeps getting taken.
Can Port Detective run from a script?
Port Detective is a desktop and tray app. For scripted use, copy the generated command from the app or use a CLI.
Try Port Detective
Get the free edition from the Microsoft Store, or buy Port Detective Pro once. If your error is EADDRINUSE, start with our EADDRINUSE fix for Windows.
Stop guessing which PID to kill, and keep your dev ports free.
Get it from Microsoft
Microsoft and Windows are trademarks of the Microsoft group of companies. Docker is a trademark of Docker, Inc. npm is a trademark of npm, Inc. Other product names are trademarks of their owners. Port Detective is not affiliated with or endorsed by any of them.
Last updated 17 October 2026. Published by Automata Labs, a software company in Canada.