kill-my-port
is a simple and efficient CLI tool that helps developers quickly free up ports by terminating processes running on them. It works across Windows, macOS, and Linux and provides an interactive mode if no port is specified.
You can use kill-my-port
instantly without installing it:
npx kill-my-port 3000
To use kill-my-port
as a command without npx
:
npm install -g kill-my-port
Now, you can run it like this:
kill-my-port 3000
kill-my-port 3000 5000 8080
This will find and terminate processes running on ports 3000
, 5000
, and 8080
.
If you run the command without specifying a port, it will list active ports and let you pick one:
kill-my-port
Example output:
🔍 Active ports:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 1234 user 22u IPv4 0x1234 0t0 TCP 127.0.0.1:3000 (LISTEN)
python 5678 user 23u IPv4 0x5678 0t0 TCP 127.0.0.1:5000 (LISTEN)
Enter a port to kill: 3000
❗ Kill process running on port 3000? (y/n): y
✅ Port 3000 has been freed.
If you try to kill a port that has no active process, it will inform you:
kill-my-port 8000
⚠️ No process is running on port 8000.
✔ Kill multiple ports at once (e.g., kill-my-port 3000 5000 8080
)
✔ Cross-platform: Works on Windows, macOS, and Linux
✔ Zero setup required: Use instantly with npx
✔ Auto-detect active ports if no port is provided
✔ Confirmation prompt before killing a process
✔ Safe & efficient
Internally, kill-my-port
executes OS-specific commands to find and terminate processes:
OS | Command Used |
---|---|
Windows | Get-NetTCPConnection + Stop-Process -Id <PID> -Force |
macOS/Linux | lsof -ti :PORT | xargs kill -9 |
This ensures proper compatibility across different operating systems.
- If using
kill-my-port
withoutnpx
, ensure it’s installed globally:npm install -g kill-my-port
- If installed but still not found, try:
npx kill-my-port 3000
If you see a permission error, try:
sudo kill-my-port 3000
- Ensure the process is actually running by using:
netstat -ano | findstr :3000 # Windows lsof -i :3000 # macOS/Linux
- Try running
kill-my-port
without a port number to list all active ports.
If you’d like to improve this tool, feel free to contribute on GitHub!
🔗 GitHub Repository: https://github.com/TenEplaysOfficial/kill-my-port
If you find kill-my-port
useful, consider supporting its development:
Patreon: https://www.patreon.com/teneplays
kill-my-port
is open-source and released under the MIT License.