kill-my-port
Version:
Easily kill processes running
166 lines (110 loc) β’ 5.17 kB
Markdown
[](https://www.npmjs.com/package/kill-my-port)
[](https://www.npmjs.com/package/kill-my-port)

[](https://github.com/TenEplaysOfficial/kill-my-port)


[](https://github.com/TenEplaysOfficial/kill-my-port/issues)
[](https://github.com/TenEplaysOfficial/kill-my-port/pulls)
[](https://github.com/TenEplaysOfficial/kill-my-port)

[](#)


# `kill-my-port` β Kill Processes Running on a Port Instantly π
`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.
## π¦ Installation
### **Option 1: Run Without Installation (NPX)**
You can use `kill-my-port` instantly without installing it:
```sh
npx kill-my-port 3000
```
### **Option 2: Install Globally (for Persistent Use)**
To use `kill-my-port` as a command without `npx`:
```sh
npm install -g kill-my-port
```
Now, you can run it like this:
```sh
kill-my-port 3000
```
## π οΈ Usage
### **1οΈβ£ Kill a Process on One or More Ports**
```sh
kill-my-port 3000 5000 8080
```
This will **find and terminate** processes running on ports `3000`, `5000`, and `8080`.
### **2οΈβ£ Auto-Detect Running Ports and Choose One to Kill**
If you run the command **without specifying a port**, it will **list active ports** and let you pick one:
```sh
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.
```
### **3οΈβ£ Handling a Port Not in Use**
If you try to kill a port that has no active process, it will inform you:
```sh
kill-my-port 8000
```
```
β οΈ No process is running on port 8000.
```
## π₯ Features
β **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**
## βοΈ How It Works
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.
## π Troubleshooting
### **1οΈβ£ Command Not Found (`kill-my-port: command not found`)**
- If using `kill-my-port` without `npx`, ensure itβs installed globally:
```sh
npm install -g kill-my-port
```
- If installed but still not found, try:
```sh
npx kill-my-port 3000
```
### **2οΈβ£ Permission Denied on macOS/Linux**
If you see a permission error, try:
```sh
sudo kill-my-port 3000
```
### **3οΈβ£ Port Not Found (`No process is running on port X`)**
- Ensure the process is actually running by using:
```sh
netstat -ano | findstr :3000 # Windows
lsof -i :3000 # macOS/Linux
```
- Try running `kill-my-port` **without a port number** to list all active ports.
## π‘ Contributing
If youβd like to improve this tool, feel free to **contribute on GitHub**!
π **GitHub Repository:** https://github.com/TenEplaysOfficial/kill-my-port
## β€οΈ Support & Funding
If you find `kill-my-port` useful, consider supporting its development:
**Patreon:** https://www.patreon.com/teneplays
## π License
`kill-my-port` is **open-source** and released under the **[MIT License](LICENSE)**.