Top
Best
New

Posted by raskrebs 11 hours ago

Show HN: Sonar – A tiny CLI to see and kill whatever's running on localhost(github.com)
101 points | 57 commentspage 2
kohexo 3 hours ago|
Honestly, pretty cool. I was wondering if something like this existed. Right now I have scripts to kill the ports I use consistently to avoid issues when developing. Kudos!
raskrebs 2 hours ago|
I looked around for a while, couldn't find anything. Someone posted about killport but never stumbled upon it. Has some features that are the same, but not all. From the reaction online people don't seem to know of other solutions like this, or have something they have made them selves in the .zshrc :)
mfkrause 7 hours ago||
I always find myself going through my zsh history for `lsof`. Will definitely check this out, seems interesting (even though I'm generally reluctant of installing third-party tools for such jobs).
raskrebs 7 hours ago|
I get that, i also often install some and forgot about them. But i felt that there was a big gap in managing multiple services running on localhost. It's pretty lightweight if that helps
moezd 8 hours ago||
Sonar as in SonarQube? That's an interesting choice for a name :)
beart 7 hours ago||
How about Sonar as in SOund Navigation And Ranging?
raskrebs 7 hours ago||
I think a cli tool that detects objects beneath the surface is a pretty intuitive name, but i was also reluctant in the beginning. But they are pretty keen on always using the qube part, i believe theirs is sonar-qube.
quotemstr 5 hours ago||
Christ Almighty I hate our industry practice of binding to some inscrutable port number on localhost. Unix domain sockets aren't that hard! They're secure against all sorts of attacks and more convenient to boot. Instead of connecting to a number, you connect to a file. An ordinary file, with an ordinary name you can mv, chmod, and rm. Boring on a good way.

So why doesn't everyone run local services over Unix sockets?

The only problems: 1) web browsers don't support AF_UNIX URI scheme, and 2) ancient versions of Java don't have built-in APIs for AF_UNIX sockets.

That's it. For these trivial reasons, we've beat our head against arbitrary opaque numbers for decades.

And so, for want of a nail, the Unix was lost.

0x457 4 hours ago||
Some random daemon binding to 3000 because it's the express default drives me nuts. I either do a Unix socket, a pick any random port if it has to bind on a port.
formerly_proven 5 hours ago||
> So why doesn't everyone run local services over Unix sockets?

> The only problems:

3) 40 years of Windows not supporting UDS.

quotemstr 1 hour ago||
Yeah, that too. Windows supports them nowadays too, just to be clear. I think we're still bottlenecked, right now, on #1 and #2 in the form of Java 8 refusing to die.
formerly_proven 40 minutes ago||
Yeah, doing the math it's actually only 33 years of not supporting AF_UNIX, but that's not really right either, since those versions of Windows didn't support any sockets. I guess the technically correct answer then is that Windows didn't support UDS for 26 years.

Which is still enough for most portable software to go "eh, localhost is fine*"

* resolving localhost is actually a pretty bad idea (yet very common) and it's way more robust to listen directly on a numeric address.

jkestner 4 hours ago||
I read the readme. :) Very nice. Thoughtful features. Get this on Homebrew!
raskrebs 4 hours ago|
I will, but the process is a bit tedious. But will look into it over the weekend
0x457 4 hours ago||
I recommend just doing a tap in the same repo rather than adding this to homebrew first.
Bradd3rs 10 hours ago||
love this, i get tired of spamming lsof -i tcp:xxxx
Doublon 9 hours ago||
The README made me realize I just needed a simple `alias local-tcp-listeners='lsof -iTCP -sTCP:LISTEN'` in my `~/.bash_aliases` :)
deadbabe 8 hours ago|||
Same, not sure why a whole cli app is needed.
paddim8 8 hours ago|||
Because it gives more context. Quite obvious if you look at the readme...
raskrebs 8 hours ago|||
Developers are nitpicky, atleast i am and i know a lot of others that are as well. So don't underestimate the value of a nice tool with good developer experience, one that's intuitive, clean and easy to use means a lot when juggling so many things during a workday. So having a clean and light implementation to make job even easier is in my opinion worth it (and thus needed) :)
raskrebs 8 hours ago|||
True, but as i write their are workarounds, the problem is that they are unintuitive, difficult to remember and don't provide all that much usability beyond listing. So these lack useful features like getting process stats, killing ports easily without having to remember the the pid after lsof and so on. I often have to kill multiple process at once after a failed cleanup. If you are into agentic coding, then having your agent create a profile for all the processes it stats, which it can easily kill of when finished is a lot easier for me atleast.

Some features on the way are: next available port; wait (wait for a host to return a successful health check before proceeding - good for migrations etc.). And lots more. It's not just about listing running ports, but a tool for managing them.

But to each their own, that's what's lovely about the many options available. But if you have anything in relation to this you think is neat, feel free to open an issue. It may be able to convince you that a simple alias won't suffice.

raskrebs 9 hours ago||
Glad to hear! Have quite a few ideas in mind so keep an eye out for some updates (one of the ideas is an easy update command). There's a couple of open enhancement ideas as well. Feel free to add any or contribute.
frankdenbow 8 hours ago||
love this, happens too often
raskrebs 7 hours ago|
Exactly, really hates it as well. Please post any issues you may have
aplomb1026 3 hours ago||
[dead]
abitabovebytes 3 hours ago||
[dead]
takahitoyoneda 7 hours ago|
[dead]
More comments...