A powerful CLI tool for managing ports and processes on your development machine. Find what's using ports, kill processes by port, check service health, and manage port conflicts.
- List Ports: Display all listening ports with process information
- Kill Processes: Kill processes by port number, PID, or name pattern
- Health Checks: Check if ports are open using TCP or HTTP health checks
- Multiple Output Formats: Support for table, JSON, and CSV output
- Cross-platform: Works on macOS, Linux, and Windows
git clone https://github.com/yourusername/portcheck.git
cd portcheck
go build -o portcheck
sudo mv portcheck /usr/local/bin/go install github.com/yourusername/portcheck@latestDisplay all listening ports on your system:
portcheck listOutput:
PORT PROTOCOL STATE PID PROCESS USER COMMAND
6379 tcp LISTEN 920 redis-server maykr /opt/homebrew/opt/redis/bin/redis-server
8080 tcp LISTEN 1234 node maykr node server.js
3000 tcp LISTEN 5678 node maykr npm start
portcheck list --port 8080portcheck list --name nodeportcheck list --pid 1234portcheck list --format json[
{
"port": 8080,
"protocol": "tcp",
"state": "LISTEN",
"pid": 1234,
"process": {
"pid": 1234,
"name": "node",
"command_line": "node server.js",
"user": "maykr"
}
}
]portcheck list --format csv > ports.csvportcheck kill --port 8080portcheck kill --pid 1234portcheck kill --name nodeportcheck kill --port 8080 --forceportcheck check localhost:8080Output:
Checking TCP port: localhost:8080
✓ Port localhost:8080 is open (response time: 1.5ms)
portcheck check http://localhost:8080/healthOutput:
Checking HTTP endpoint: http://localhost:8080/health
✓ HTTP endpoint is healthy (status: 200, response time: 15ms)
portcheck check localhost:8080 --timeout 10sList all listening ports with process information.
Flags:
-p, --port <number>: Filter by port number-n, --name <pattern>: Filter by process name--pid <number>: Filter by process ID-f, --format <format>: Output format (table/json/csv)
Kill processes by port, PID, or name.
Flags:
-p, --port <number>: Kill process using specific port--pid <number>: Kill process by PID-n, --name <pattern>: Kill all processes matching name pattern-f, --force: Force kill (SIGKILL instead of SIGTERM)
Check if a port is open or service is healthy.
Arguments:
<host:port>: Check TCP port (e.g., localhost:8080)<url>: Check HTTP endpoint (e.g., http://localhost:8080/health)
Flags:
-t, --timeout <duration>: Connection timeout (default: 5s)
When you get an "address already in use" error:
# Find what's using the port
portcheck list --port 3000
# Kill the process
portcheck kill --port 3000Check if your services are running:
# Check database
portcheck check localhost:5432
# Check web server
portcheck check http://localhost:8080/healthKill all instances of a development server:
portcheck kill --name nodeGenerate a report of all listening ports:
portcheck list --format csv > ports-report.csv- Go 1.21 or higher
go build -o portcheckgo test ./...portcheck uses gopsutil for cross-platform process information, providing consistent behavior across:
- macOS (darwin)
- Linux
- Windows
- cobra - CLI framework
- tablewriter - Table output
- color - Terminal colors
- gopsutil - Cross-platform process info
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details
Built with focus and precision for developers who need reliable port management.