A powerful, cross-platform CLI tool for port and process management with advanced task manager capabilities. Detect, kill, and monitor both ports and processes with an intuitive interface, smart safety features, and beautiful visualizations.
⭐ If you find this tool helpful, please consider giving it a star on GitHub!
- Smart Detection - Automatically finds processes using specific ports
- Multiple Port Operations - Kill multiple ports or port ranges at once
- Interactive Mode - Visual selection interface for choosing ports to kill
- Watch Mode - Continuously monitor and auto-kill processes on a port
- Port Listing - View all ports currently in use
- Port Presets - Quick commands for common development ports
- Process Listing - View all processes with CPU, RAM, GPU usage
- Resource Monitoring - Real-time system and process monitoring
- Smart Safety - Prevents killing critical system processes
- Process Tree - Visualize process hierarchies
- High-Usage Detection - Find and kill resource-intensive processes
- Pattern Matching - Kill processes by name with wildcard support
- Export & Reports - Generate JSON/CSV reports of processes
- Safe Termination - Confirms before killing (unless forced)
- Action Logging - Keeps a history of all operations
- Beautiful Output - Color-coded messages and formatted tables
- Cross-Platform - Works seamlessly on Windows, macOS, and Linux
npm install -g portdoctornpx portdoctor <port># Kill a single port
portdoctor 3000
# List all ports in use
portdoctor list
# Interactive mode
portdoctor interactive
# Kill multiple ports
portdoctor 3000,8080,5000 --force
# Kill port range
portdoctor 3000-3010 --force
# Watch a port
portdoctor watch 3000
# Kill common dev ports
portdoctor dev --force# List all processes
portdoctor process list
# List only user processes
portdoctor process list --user
# Sort by memory usage
portdoctor process list --sort memory --top 10
# Get detailed process info
portdoctor process info 1234
# Kill a process safely
portdoctor process kill 1234
# Kill high-usage processes
portdoctor process kill-high --cpu 80 --memory 2048
# Kill processes by name
portdoctor process kill-name "node*" --force
# Real-time monitoring
portdoctor process monitor
# Show process tree
portdoctor process tree --user
# Export processes
portdoctor process export --jsonKill a process using a specific port:
portdoctor 3000
portdoctor 3000 --force # Skip confirmation
portdoctor 3000 --silent # No logging
portdoctor 3000 -f -s # Combined optionsKill processes on multiple ports at once:
portdoctor 3000,8080,5000
portdoctor 3000,8080,5000 --forceKill all processes in a port range:
portdoctor 3000-3010
portdoctor 8000-8100 --forceDisplay all ports currently in use:
portdoctor listSelect ports to kill from a visual list:
portdoctor interactive
portdoctor interactive --force # Skip final confirmationContinuously monitor a port and auto-kill any process that uses it:
portdoctor watch 3000Get detailed information about a process using a port:
portdoctor info 3000Export port usage information:
portdoctor report --json # JSON format
portdoctor report --csv # CSV formatKill common development ports (3000, 8080, 5000, 4200, 8000, 9000):
portdoctor dev
portdoctor dev --forceView all processes with resource usage:
portdoctor process list # All processes
portdoctor process list --user # User processes only
portdoctor process list --sort cpu # Sort by CPU
portdoctor process list --sort memory # Sort by memory
portdoctor process list --top 10 # Top 10 processes
portdoctor process list --filter "node" # Filter by nameGet detailed information about a specific process:
portdoctor process info 1234Output includes:
- Process name, PID, parent PID, user
- CPU, memory, GPU usage
- Command line and executable path
- Open ports
- System process indicator
- Safety status
Safely kill a process by PID:
portdoctor process kill 1234
portdoctor process kill 1234 --forceNote: System-critical processes are protected and cannot be killed.
Kill processes consuming excessive resources:
portdoctor process kill-high # Default: CPU > 50%, Memory > 1GB
portdoctor process kill-high --cpu 80 # CPU > 80%
portdoctor process kill-high --memory 2048 # Memory > 2GB
portdoctor process kill-high --cpu 70 --memory 1500 --forceKill processes matching a name pattern (supports wildcards):
portdoctor process kill-name "node*"
portdoctor process kill-name "python*" --force
portdoctor process kill-name "*server*"Monitor processes in real-time:
portdoctor process monitor # Default: 2s interval, top 10
portdoctor process monitor --interval 1000 # 1s refresh
portdoctor process monitor --top 20 # Show top 20Press Ctrl+C to exit.
Visualize process hierarchies:
portdoctor process tree # All processes
portdoctor process tree --user # User processes only
portdoctor process tree --pid 1234 # Highlight specific PIDExport process information to a file:
portdoctor process export --json # JSON format
portdoctor process export --csv # CSV format
portdoctor process export --json --user # User processes only
portdoctor process export --json --output my-processes.jsonPortDoctor includes comprehensive safety measures to prevent system crashes:
- System Process Protection: Maintains a whitelist of 40+ critical Windows/Unix processes
- Path Validation: Checks executable paths (System32, Windows, /sbin, etc.)
- User Validation: Identifies system users (NT AUTHORITY\SYSTEM, root, etc.)
- PID Range Checks: Protects very low PIDs (< 100 on Windows, < 10 on Unix)
- Immutable Protection: Even with --force flag, system processes cannot be killed
- Clear Warnings: Displays detailed reasons when processes cannot be killed
- Windows: System, csrss.exe, lsass.exe, svchost.exe, dwm.exe, explorer.exe, etc.
- Unix/Linux: init, systemd, kthreadd, launchd, etc.
portdoctor [ports] [options] Kill single/multiple ports or range
portdoctor list List all ports in use
portdoctor interactive [options] Interactive port selection
portdoctor watch <port> Watch and auto-kill on port
portdoctor info <port> Show detailed process info
portdoctor report [--json|--csv] Generate port usage report
portdoctor dev [options] Kill common dev ports
portdoctor process list [options] List all processes
portdoctor process info <pid> Show detailed process info
portdoctor process kill <pid> Kill a specific process
portdoctor process kill-high [options] Kill high-usage processes
portdoctor process kill-name <pattern> Kill by name pattern
portdoctor process monitor [options] Real-time monitoring
portdoctor process tree [options] Show process hierarchy
portdoctor process export [options] Export process information
-f, --force Force kill without confirmation
-s, --silent Silent mode (no logs)
-V, --version Output version number
-h, --help Display help
# Kill all common dev ports at once
portdoctor dev --force# List top 10 processes by CPU
portdoctor process list --sort cpu --top 10
# Kill processes using > 80% CPU
portdoctor process kill-high --cpu 80 --force# Find node processes
portdoctor process list --filter "node"
# Get detailed info
portdoctor process info 1234
# Monitor in real-time
portdoctor process monitor# Kill all node processes
portdoctor process kill-name "node*" --force
# Kill all python processes
portdoctor process kill-name "python*" --force# Export all processes
portdoctor process export --json
# Show process tree
portdoctor process tree --user
# List all ports
portdoctor listPortDoctor maintains a history of all operations:
- Windows:
C:\Users\<username>\.portdoctor\history.log - macOS/Linux:
~/.portdoctor/history.log
[11/6/2025, 2:30:45 PM] Killed PID 12345 on port 3000 (node)
[11/6/2025, 3:15:22 PM] Killed PID 67890 (node.exe - CPU: 85.2%, Mem: 512MB)
- Windows:
netstat -ano+tasklist - macOS/Linux:
lsof -i
- Uses
systeminformationpackage for cross-platform metrics - Real-time CPU, memory, GPU monitoring
- Process tree hierarchy mapping
- Smart safety validation
- Windows:
taskkill /F - macOS/Linux:
kill -9
- Node.js >= 18.0.0
- Free up ports blocked by crashed development servers
- Quickly restart services during development
- Find and kill resource-intensive processes
- Monitor system resource usage in real-time
- Clean up stuck or zombie processes
- Audit running processes and port usage
- Automate port/process clearing in build scripts
- Troubleshoot port conflicts in CI/CD pipelines
- Generate reports for system analysis
- Visualize process relationships
If you get "Permission denied" errors:
- Windows: Run as Administrator
- macOS/Linux: Use
sudo portdoctor ...
If a process cannot be killed:
- Check if it's a system process (protected for safety)
- Verify you have sufficient permissions
- Try running with elevated privileges
GPU usage per process is not always available:
- Requires NVIDIA/AMD GPU monitoring tools
- May not be supported on all systems
- Will show "N/A" when unavailable
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please read our Contributing Guidelines for more details.
Thanks to all contributors who have helped make PortDoctor better!
MIT © Mahesh Sharan
If you find this tool helpful, please:
- ⭐ Star the repository on GitHub
- 🐛 Report bugs and request features via Issues
- 📢 Share it with other developers
- 💬 Follow @MaheshSharan for updates