HN
Today

Show HN: Sonar – A tiny CLI to see and kill whatever's running on localhost

Sonar is a new CLI tool designed to simplify the inspection and management of processes running on localhost, tackling the common developer headache of port conflicts and orphaned services. It streamlines tasks traditionally handled by complex lsof commands, offering features like Docker integration, process killing, and log tailing. Its single-binary, dependency-free nature and intuitive interface make it a popular solution for a persistent development pain point.

9
Score
4
Comments
#10
Highest Rank
7h
on Front Page
First Seen
Mar 20, 12:00 PM
Last Seen
Mar 20, 6:00 PM
Rank Over Time
23101412202723

The Lowdown

Sonar is a command-line interface (CLI) utility built to alleviate the frustrations developers face when managing services and applications listening on localhost. Tired of wrestling with lsof and manually identifying rogue processes or Docker containers hogging ports, the creator developed Sonar as a comprehensive, user-friendly alternative.

Key features and functionalities of Sonar include:

  • Comprehensive Port Listing: Displays all services listening on localhost, enriched with details like process name, Docker container info (name, image, port), resource usage, and clickable URLs. It intelligently filters out irrelevant system and desktop applications by default.
  • Process Management: Enables easy killing of processes by port number, with options for SIGTERM or SIGKILL. It can also stop all Docker containers associated with a filter or a Compose project.
  • Logging and Inspection: Allows users to tail logs for Docker containers and native processes, and inspect detailed information about any port, including command, user, CPU/memory usage, and health check results.
  • Dynamic Monitoring: The watch command provides real-time monitoring of port changes, with configurable polling intervals and desktop notifications.
  • Dependency Graph: Visualizes connections between listening services, revealing which components are communicating with each other.
  • Profiles and Automation: Users can create profiles to snapshot expected ports for a project, then quickly check their status or tear them down.
  • Utilities: Includes commands to open URLs in a browser, map ports for proxying traffic, and a macOS system tray application for live port viewing.
  • Platform Support: Works on macOS (using lsof) and Linux (using ss), aiming for broad compatibility.

Sonar provides a powerful, consolidated toolset that simplifies a notoriously fiddly aspect of software development, making it easier to maintain a clean and functional local development environment without arcane shell commands.

The Gossip

Localhost Love

Many commenters express immediate enthusiasm for Sonar, highlighting its ability to solve a common and annoying developer problem: managing `localhost` ports and processes. They appreciate the convenience and user-friendliness of a dedicated tool compared to repetitive, complex `lsof` commands, especially when dealing with Docker containers or orphaned development servers. The author's personal experience of building the tool to address their own pain points resonated strongly with the community.

Alias Alternative

While generally positive, some users point out that a portion of Sonar's functionality, particularly identifying listening ports, can be achieved with simple `lsof` aliases. This highlights a segment of users who might prefer lightweight shell aliases for specific tasks, though it implicitly acknowledges Sonar's broader, more integrated feature set goes beyond mere port identification.

Developer's Dialogue

The author actively participates in the comments, demonstrating responsiveness to feedback and outlining future plans for Sonar, such as an easy update command. They also encourage community contributions and ideas, fostering an open-source development environment. This engagement builds trust and excitement for the tool's ongoing evolution.