GitHub - raskrebs/sonar: CLI tool for inspecting and managing services listening on localhost ports
Summary
Sonar is a single-binary CLI that replaces the lsof -iTCP | grep workflow with a rich, Docker-aware port inspector. It lists every service listening on localhost, shows container names, Compose projects, resource usage, and offers kill/logs/attach/watch/wait/profile commands all by port number.
Key Insight
- Goes well beyond simple port listing:
sonar list --statsadds CPU, memory, state, uptime per process/container.sonar graphmaps inter-service connections (e.g. backend to postgres) and can output Graphviz DOT. sonar waitwith--http=/healthis the standout feature for scripting: blocks until an endpoint returns HTTP 200-399, not just TCP open, solving the common “service accepts connections before it’s actually ready” race condition in CI/dev scripts.sonar profilelets you snapshot expected ports for a project, thensonar upchecks if they’re all running andsonar downtears them all down — essentially a lightweight service orchestrator on top of whatever you’re already using.- Hides macOS noise (Figma, Discord, AirPlay, system daemons) by default, so the output is immediately useful for dev work.
- Supports remote machines via
--host user@server(SSH), so you can inspect staging/dev servers the same way. sonar mapdoes quick port forwarding (proxy from one local port to another), andsonar nextfinds free ports in a range — both useful for multi-service setups where port collisions are common.- Single binary install via curl, no dependencies. Works on macOS (lsof) and Linux (ss).