portls
Modern cross-platform port inspector in Rust. Clean replacement for ss, netstat, and lsof.
Installation
Or build from source:
This installs the ports command.
Usage
List all listening ports
┌──────┬───────┬───────┬─────────────┬─────────────┐
│ PORT │ PROTO │ PID │ PROCESS │ ADDRESS │
├──────┼───────┼───────┼─────────────┼─────────────┤
│ 80 │ tcp │ 1234 │ nginx │ 0.0.0.0:80 │
│ 443 │ tcp │ 1234 │ nginx │ 0.0.0.0:443 │
│ 3000 │ tcp │ 5678 │ node │ 127.0.0.1 │
│ 5432 │ tcp │ 9012 │ postgres │ 127.0.0.1 │
└──────┴───────┴───────┴─────────────┴─────────────┘
4 result(s)
Query by port or process name
Show established connections
┌──────┬───────┬──────┬──────────┬─────────────────┬──────────────────┐
│ PORT │ PROTO │ PID │ PROCESS │ LOCAL │ REMOTE │
├──────┼───────┼──────┼──────────┼─────────────────┼──────────────────┤
│ 443 │ tcp │ 1234 │ curl │ 192.168.1.5 │ 93.184.216.34 │
└──────┴───────┴──────┴──────────┴─────────────────┴──────────────────┘
Watch mode with live updates
New entries are highlighted in green.
Kill processes
Interactive mode
Use ↑/↓ or j/k to navigate, Enter to select, q to quit.
Real-time TUI (htop for ports)
Controls:
Tab- Toggle between listening/connections modep/i/n- Sort by port/pid/name↑/↓/j/k- NavigatePgUp/PgDn- Page navigationq- Quit
New ports are highlighted green for 3 seconds.
Port usage history
Track port usage over time with SQLite-backed history:
Example cron job for continuous monitoring:
# Record port state every 5 minutes
History data is stored in ~/.local/share/ports/ports_history.db.
Docker container awareness
When ports are forwarded by Docker, ports automatically shows which container they map to:
┌──────┬───────┬──────┬──────────────┬───────────────┬──────────────┐
│ PORT │ PROTO │ PID │ PROCESS │ CONTAINER │ ADDRESS │
├──────┼───────┼──────┼──────────────┼───────────────┼──────────────┤
│ 80 │ tcp │ 1234 │ docker-proxy │ nginx-prod │ 0.0.0.0:80 │
│ 443 │ tcp │ 1234 │ docker-proxy │ nginx-prod │ 0.0.0.0:443 │
│ 5432 │ tcp │ 5678 │ docker-proxy │ postgres-db │ 0.0.0.0:5432 │
│ 3000 │ tcp │ 9012 │ node │ - │ 127.0.0.1 │
└──────┴───────┴──────┴──────────────┴───────────────┴──────────────┘
You can also query by container name:
Filter and sort
JSON output
Shell Completions
# Generate and save
# Or eval dynamically in shell config
| # ~/.config/fish/config.fish
Platform Support
- Linux: Native
/proc/netparsing for maximum performance - macOS: Uses
lsoffallback vialistenerscrate - Others: Generic
listenerscrate fallback
Examples
# Find what's blocking port 8080
# Monitor all network activity in real-time
# Kill all Node.js processes on any port
# Export all listening ports as JSON
# Watch PostgreSQL connections
# Interactively select and kill a port