destroy-port
v1.0.0
Published
Kill all processes running on a given port. Works on Windows, macOS, and Linux.
Maintainers
Readme
killport
Kill all processes running on a given port — Windows, macOS, and Linux.
No external dependencies. Pure Node.js.
Install
Global (recommended — use anywhere in terminal)
npm install -g .Run this command inside the
killportfolder after unzipping.
Local (use in a project)
npm install --save-dev .Usage
CLI
# Kill everything on port 3000
killport 3000
# Kill multiple ports at once
killport 3000 5000 8080
# Also works as:
kill-port 3000Programmatic (Node.js)
const { killPort, getPIDsOnPort } = require('killport');
// Kill port 3000
const result = killPort(3000);
console.log(result);
// { port: 3000, killed: [12345], notFound: false }
// Just find PIDs without killing
const pids = getPIDsOnPort(3000);
console.log(pids); // [12345]Output Examples
✔ Killed process [PID: 14732] on port 3000
✔ Killed processes [PID: 8821, 9002] on port 5000
ℹ No process found on port 8080Platform Support
| Platform | Method used |
|----------|------------------------------------|
| Windows | netstat -ano + taskkill /F /PID|
| macOS | lsof -ti:<port> + kill -9 |
| Linux | lsof -ti:<port> + kill -9 |
API
killPort(port)
Kills all processes on the given port.
- port
number | string— Port number (1–65535) - Returns
{ port, killed: number[], notFound: boolean }
getPIDsOnPort(port)
Returns an array of PIDs using the port without killing them.
- port
number | string - Returns
number[]
License
MIT
