6 ms·
I Got Sick of Remembering Port Numbers
- yunruse 5mo agoThis project is essentially "give me some metadata & a command which takes env $PORT, and I'll handle the rest". Which is neat! I am also sick of handling port numbers - I end up allocating them on a schema to different services, so for testing I can spool any VM/service combination and avoid crossover. But if I want the same service twice, ah... It always fascinated me that ports don't have any kind of textual resolver, so you can bind to `:1234` and also say "please also accept `:foobar`". But that would itself require some kind of "port resolver" on a device, and that's another service to break and fix :)
- winstonwinston 5mo agoThere is /etc/services to map port numbers to service names, and using getportbyname() to resolve port numbers.
- pratikdeoghare 5mo agoWhat I do is use a hash function to derive port number from service name.
- kasperni 5mo agoNot the same, but omeone recently posted this "port" tool here on HN: https://github.com/raskrebs/sonar https://github.com/raskrebs/sonar
- thunderbong 5mo agoHN Thread https://news.ycombinator.com/item?id=47452515 https://news.ycombinator.com/item?id=47452515
- zdw 5mo agoIt's like someone should make a file... maybe in /etc ... and put short names for services in it... maybe it could be called /etc/services...
- tolciho 5mo agoAnd then they might code up some sort of service lookup tool thingy to use on the train wreck that is the modern web. $ getent services gopher gopher 70/tcp
- otabdeveloper4 5mo agoHeck, maybe even `resolvectl service`?
- pratyahava 5mo agothis is a nice idea, but idk why, in macos if i do `nc -l 127.0.0.1 gopher` and then try to open url "http://127.0.0.1:gopher/ http://127.0.0.1:gopher/" - safari does not open it, no requests visible in the `nc` output. also `curl -v http://127.0.0.1:gopher/ http://127.0.0.1:gopher/` gives error message * URL rejected: Port number was not a decimal number between 0 and 65535 * Closing connection curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535 so the ports are named, it is nice, but in practice it does not make life easier.
- bandie91 5mo ago> http://...:gopher is it http or gopher? :)
- pratyahava 5mo agoi chose gopher port just as an example. try with any other service name mapped to a port number from /etc/services and the result will be the same. the OP's goal was to use many http/https services, so we are talking about many http(s) services. i just wanted to make the point that even if you have service names in /etc/services, it is not possible to use that names easily to host/access http(s) services.
- pyreal 5mo agoI created something similar to help me spin up complex apps in multiple worktrees with full port orchestration: https://outport.dev/ https://outport.dev/
- hahahacorn 5mo agoBind to Port 0
- CGamesPlay 5mo agoI've built this twice before. The main problem that I hit is that the AI agents suck at the process lifecycle management: leaving processes alive, starting the same daemon multiple times, etc. From a brief glance over the code I like the approaches I see. Using the `/etc/resolver/` mechanism is a new trick to me! The interesting part to me isn't the port numbers, it's the automatic service start/stop, including idle route shutdown.
- elchief 5mo agoI'm slightly annoyed that vite's default port isn't 8483
- chrisweekly 5mo agowhy?
- kseistrup 5mo agoVITE typed on a T9 keyboard is 8483.
- ButlerianJihad 5mo agoT9 is predictive and based on a dictionary and training. If you type "8483" on T9, your phone may offer "THUD" or "TITE" or all three, as choices. But with a normal telephone keypad, if you dial, e.g. "(800) 555-VITE" then you will always dial "8483". https://en.wikipedia.org/wiki/Phoneword https://en.wikipedia.org/wiki/Phoneword Also, a service port is always qualified by its protocol. There are separate port namespaces for each IP protocol that uses ports. "8483" is not a service port, until you spell it out: 8483/tcp or 8483/udp or 8483/sctp or 8483/dccp etc. A TCP stream, for example, consists of a tuple: src:port1 dst:port2
- hdjrudni 5mo ago5173 spells Vite... 173 looks like ITE 5 in roman numerals is V.
- nektro 5mo agoi have something like this too, currently a 60 line nodejs file
- arjie 5mo agoThis is a valid concern, certainly. I use kube for most things so it's not a problem, but my homeserver and its apps run on quadlets that I manage. In my case, I just added a README.md in the server account folder that each project's CLAUDE.md or whatever is configured to read. Then it selects a port and sticks that in the document and to be honest I have a few tens of services and it works. Haha, a direct replacement of machine for my own process.
- deleted 5mo ago[deleted]
- system2 5mo agoIt is funny, I just built something like this last week and named it "Network". Additionally it scans for any type of data packages arriving at the SonicWall and sees if they are approved by me or not. I am paranoid after using TP Link at home like a dumbass.
- iib 5mo agoI am very out of the loop. What is wrong with TP Link? What are the risks with it?
- system2 5mo agoChinese spyware. https://www.reddit.com/r/msp/comments/1pxe1zc/tplink_ban_proposal_backed_by_seven_government/ https://www.reddit.com/r/msp/comments/1pxe1zc/tplink_ban_pro... https://www.pcmag.com/news/facing-router-ban-tp-link-tells-fcc-its-investing-hundreds-of-millions https://www.pcmag.com/news/facing-router-ban-tp-link-tells-f... https://www.nytimes.com/wirecutter/reviews/foreign-made-wi-fi-routers-ban/ https://www.nytimes.com/wirecutter/reviews/foreign-made-wi-f... Just search for "TP Link ban", you will see a lot of news. I switched to SonicWall + Ubiquiti + my own monitoring software to be safe. I should've done it years ago, but I was lazy.
- dfordp11 5mo ago[dead]
- isodude 5mo agoWhy not resolve everything with UNIX sockets instead, that way you can have them named and scoped instead, hiding behind port 443, since it's mosly HTTP anyway.
- tdeck 5mo agoDoes this work in the browser? How will paths to different resources used by the web app work?
- dvhh 5mo agoworks with curl, maybe there is a case to either build a proxy for UDS and expose them to a browser, or open a request ticket to browser maintainers to support UDS
- isodude 5mo agoIt depends on how you register things. * Given that you can easily start up your own CA in a test bed, just use different domain names. * Or use IP addresses directly, given that IPv6 i pretty abundant it's easy to just listen on many addresses at the same time. A nice thing is to just put the port number is the last octets: fd01::9000, fd01::0003:5565. If it's HTTPS you always use port 443, if it's another protocol, use another port. With iptables/nft you can translate all port 443 traffic towards a /96 to a single IP. * Firefox does not seem to understand unix domain sockets, https://news.ycombinator.com/item?id=27941552 https://news.ycombinator.com/item?id=27941552. I'm assuming that you have a gateway in front that handles that aspect. * Proxies in Firefox seems to understand that though, which means you can have a proxy that translate to unix sockets locally. That means you can basically run it to a namespaced application, using only http://<service>.localhost.
- magicalhippo 5mo agoI know it's mixing of layers, but I can't help but feel the IPv6 transition missed the boat when they didn't just get rid of ports in the process. They've changed so much else anyway. Want to run another webserver instance or whatever on your computer? Get the OS to allocate a new IP for it. Ports be damned. Could be implemented in a backwards compatible way by requiring all IPv6 TCP/UDP traffic to use a fixed port number.
- pratyahava 5mo agoipv6 packet does not have any port field. ports are on the level of tcp and udp, and you don't have to use tcp or udp on top of ipv6. ipv4 packet does not have any port information as well.
- magicalhippo 5mo ago> ipv6 packet does not have any port field Yes, that's why I said I know it was mixing of layers. However ports are a layer violation in a strict sense, introduced as a workaround because there was no easy way to just add thousands of new IPs to a single host back in the IPv4 days. No need to continue a workaround that causes grief on a daily basis.
- allarm 5mo agoWhat do you mean? You’ll still have to use TCP or UDP over IPv6, and both of those protocols use ports. Nothing is stopping you from creating a transport protocol that doesn’t use ports if you want to, but that has nothing to do with the network layer.
- magicalhippo 5mo agoI mean that to connect to a service you wouldn't need to know the port, the IPv6 address would be enough. This is why I consider ports a layer violation of sorts. You never talk to a machine with TCP/UDP, you talk to a service on a machine. And so as it is the full address to the service isn't just the layer 3 address. As I mentioned this would be especially interesting when hosting multiple services, same or different, on the same machine since there would be no port conflict.
- tdeck 5mo agoWhat is the benefit of using HTTPS for this particular use case?
- t0mas88 5mo agoSome browser functions only work over https, localhost is the exception. So if you change localhost:5173 to myapp.vibe it needs a valid certificate.
- swiftcoder 5mo agoAnd localhost being the exception is often quite painful - I've stuck into several projects that worked just fine on localhost, and then were a pain in the neck to convert to run in secure contexts
- hotfixguru 5mo agoVercel’s portless is a great alternative, but unfortunately it doesn’t work well with oauth flows. I’ve built portmap[0] to solve that. Also comes with skills which makes it work really great with coding agents (instructions in the readme). [0] https://github.com/JonasKs/portmap https://github.com/JonasKs/portmap
- lainzhow 5mo agoI wonder why not use nginx and some local DNS settings to just serve all these local services under a new, local URL. Not too long ago I had a similar issue and solved with that.
- indigodaddy 5mo agoI mean, that's essentially what he's recreating here it looks like
- gbalduzzi 5mo agoI did the same using caddy for ease of getting https certificates
- riffraff 5mo agoI think about a decade ago pow did something similar, but using the .test domain, and perhaps ruby specific https://github.com/basecamp/pow/tree/master https://github.com/basecamp/pow/tree/master
- sakesun 5mo agoAspire.dev should be mentioned here.
- hboon 5mo agoI use Cloudflare Tunnel so most of the products I build are exposed and listed there. I just add comments for those that aren't exposed (eg. browser extension dev port) to that file too. A single doc means coding agents know to look there and keep it updated too.
- roywashere 5mo agoI hate these signs of LLM generated texts so much!! > The real annoyance is that it wasn’t just one machine. It was layers.
- PufPufPuf 5mo agoThere is no need to come up with "local TLDs" like .vibe, .local, .test and so on -- there is already an industry convention! macOS and most Linux distros support subdomains of localhost, so <anything>.localhost works. You still need the reverse proxy to do the host->port mapping, but you save yourself local DNS fiddling.
- locknitpicker 5mo ago> There is no need to come up with "local TLDs" like .vibe, .local, .test and so on -- there is already an industry convention! macOS and most Linux distros support subdomains of localhost, so <anything>.localhost works. That would work if your goal was to route traffic to localhost. What if it isn't? There are reasons why the likes of example.com exists.
- ButlerianJihad 5mo agoIt looks like this will win: https://en.wikipedia.org/wiki/.internal https://en.wikipedia.org/wiki/.internal example.com, and the reserved TLD ".example", exist for technical documentation and writing. If you are writing a comment on HN, or a curriculum for a networking class, then you can discuss "foo.example.com connects to bar.example.com" or "Let's hypothesize about two offices called accounts.example and human-resources.example" The "example" domains are never supposed to reflect anything that is actually deployed onto LANs, or test labs, or the Internet, current situation notwithstanding. https://en.wikipedia.org/wiki/.example https://en.wikipedia.org/wiki/.example There are, likewise, IPv4 and IPv6 ranges that are reserved to be used in documentation. Not the 192.168.0.0/24 or 10.0.0.0/8, but separate ranges that writers only write about, and are never deployed, not even in private. localhost is only ever going to be the loopback interface, never across a network: https://en.wikipedia.org/wiki/.localhost#Conventional_use https://en.wikipedia.org/wiki/.localhost#Conventional_use See also: https://en.wikipedia.org/wiki/.test https://en.wikipedia.org/wiki/.test The latter article lists foreign-language TLDs which serve the same purpose. Some proposals are described here: https://en.wikipedia.org/wiki/.home https://en.wikipedia.org/wiki/.home
- 5mo ago
- tylorr 5mo agoI use the tailscale services feature for this, added benefit is I get https.
- Hard_Space 5mo agoI use subdomains on an OVH VPS, since I want to access the services outside the network, so I can use freshrss.mydomain.com. But anything that can rationalize port number sprawl is welcome.
- lihanghanger 5mo agoThis is a neat approach. One thing I wonder about is how it handles services that use the same port number across different protocols (like 443 for both HTTPS and SMTPS). The /etc/services file approach has the same ambiguity, but at least it lists the protocol alongside the port. A lookup table that includes protocol would be more robust for mixed environments.
- tibtof 5mo ago[dead]
- lelanthran 5mo agoI think this product demonstrates the atrophying of thought that results from too much LLM usage: design was obviously a long back-and-forth with a sycophantic LLM. I find out what all my local servers are by `cat /etc/hosts`, because I put them in there. They run using an entry in the nginx config. For short-lived stuff I don't even bother with that, I just use `whatever.localhost`. If there was no LLM, author would have put a little more thought into this, maybe did a google search, and realised that all he needed were two shell scripts. The more you use LLMs, the less you actually think > The real annoyance is that it wasn’t just one machine. It was layers. > I wanted a simple launcher for all the things that aren’t traditional desktop apps. Not Finder, Alfred or Raycast. The entire damn article is like this - why would I trust software to run on my local machine when it was written by someone who did not even take care writing a blog post? How much care would they have possibly put into reviewing their vibe coded slop if they couldn't even bother to review their blog post?
- firefoxd 5mo agoThat was my exact post a couple days ago: https://news.ycombinator.com/item?id=47936315 https://news.ycombinator.com/item?id=47936315 (didn't get much traction)
- skeledrew 5mo ago> I put them in there That seems to run orthogonal to this. The primary benefit I see here is not having to care at all what ports apps are actually starting on. Just run them, and access them by name. Same as a regular website on the internet where one doesn't care about the IP. > How much care would they have possibly put into reviewing Just enough to ensure that it works for them, which is what really matters. Others go in knowing that as well, and add/change that base to their own preference. That's the world we're now in.
- lelanthran 5mo ago> Just enough to ensure that it works for them, which is what really matters. If that's what really mattered they wouldn't have posted an article they didn't write trying to get traction on a product they didn't create from a userbase that doesn't need it.
- firefoxd 5mo agoThere's a simple method you can use with nginx and /etc/hosts, I wrote about it couple days ago [0]. I used it for an internal demo recently and realized that a new breed of devs have never seen a non localhost url run locally. [0]: https://idiallo.com/blog/say-no-to-localhost3000-use-custom-domains https://idiallo.com/blog/say-no-to-localhost3000-use-custom-...
- Quarrel 5mo agoI essentially do this. Super simple. (although I use rewrites at my dns layer for the whole local lan, but whatever) It also solves issues my password manager has with multiple services on the one host but with different ports, but putting each on their own 2nd level domain.
- chuckadams 5mo agoCustom domain is nice if you're planning on a real host later, but nowadays you can just use the .localhost domain and skip the whole /etc/hosts editing thing.
- danfritz 5mo agoAlternative https://github.com/peterldowns/localias https://github.com/peterldowns/localias Granted no fancy UI to start and stop things but is it really needed? Tbh this is not a single binary you need dnsmasq go and other things
- junon 5mo agoThis is literally what mDNS is for. Didn't even know that it was a thing until I needed it for some custom firmware I was writing recently. It's like DNS but also has service port advertisements.
- swiftcoder 5mo agoI like localias[1] for this problem. Not only do you get nice aliases for all your local ports, but you also get nice Caddy-managed TLS certs for them [1]: https://github.com/peterldowns/localias https://github.com/peterldowns/localias
- tasuki 5mo agoHuh when I start a service in dev, I just click on the link in the terminal to visit the url. What is even the problem?
- joshka 5mo ago*.localhost works btw https://datatracker.ietf.org/doc/html/rfc6761#section-6.3 https://datatracker.ietf.org/doc/html/rfc6761#section-6.3
- deleted 5mo ago[deleted]
- bennett_dev 5mo agoSounds similar to Vercel‘s portless CLI (https://portless.sh/ https://portless.sh/)
- kazinator 5mo agoThe file /etc/services maps names to port numbers, like /etc/hosts does for hosts. E.g. "telnet localhost ssh" takes you to port 22 (not the default 23 for telnet). This works because /etc/services maps "ssh" to "22". If you're sick of remembering port numbers, create some entries in your /etc/services. Of course, only programs which use getservbyname to resolve port numbers will accept your names.
- saidnooneever 5mo agomaintaining services files. i dont know why people keep insiting on that file while there are perfectly fine commands to pull from your boxes what is holding what port. that is all besides the point though if you look at what you should be doing and keeping all this information in some kind of asset management system from which you can deploy things (which is kinda what k8s and docker etc. try to do (miserably)). unless you are binding stuff to random ports on random boxes there is no need to do any of it at runtime and you can just consult your bookkeeping (for which etc services lacks a lot of details to use...)
- stuaxo 5mo agoInteresting. I've been wanting something like this for local Dev, but I think more: Per user DNS. So if the process doing the lookup is my own then redirect to the named service.
- skeledrew 5mo agoNice. An instant disappointment that there's no Linux support, but adding it should be a quick prompt away.
- kamma4434 5mo agoI thought that was the reason ‘lsof -i -P’ existed
- jameshart 5mo ago[dead]
- BrandiATMuhkuh 5mo agoCool project. Just yesterday I looked at https://portless.sh/ https://portless.sh/ which is vercels take.
- OriPekelman 5mo agoThis is really amusing. Because absolutly eveyrone I know vibe-coded this thing. I think the first one was https://github.com/ralt/dns-to-port https://github.com/ralt/dns-to-port possibly mine is second (but it is very much a joke so I am not linking it) .. Vercel later did https://github.com/vercel-labs/portless https://github.com/vercel-labs/portless and I would imagine quite a few others. Zeitgeist. Also this does probably mean its kinda useful. And that none of us can get bothered to "Google" if a thing that does the same thing already exists. Currently vibing, on a train, a spaced repetition thing for my kid - because I needed a specific list of countries - and its faster to create the whole app rather than figure-out how to find one that would do this.
- allarm 5mo ago> a spaced repetition thing anki?...
- michaelcampbell 5mo agoI do exactly this for the half dozen or so ports that I do care to remember.
- hollow-moe 5mo agoYou might also use another "localhost", the whole 127.0.0.0/8 is reserved for them. macos is a pain there because it only binds 127.0.0.1 to the local interface but you can add more manually.
- deafpolygon 5mo agoUnrelated, but that site is unreadable to me... dark grey on black?
- allarm 5mo agoPeople will do anything to avoid learning the basics. Nothing new.
- rasso 5mo agoDo you have a link for me? I'd like to learn them, but find it really hard to find them. For example, I had never heard about etc/services until 2 minutes ago
- allarm 5mo agoCheck out this book: Unix and Linux System Administration Handbook by Evi Nemeth et al. I'm pretty sure Arch wiki is worth reading, too.
- c-hendricks 5mo agoA few other solutions / notes: Your browser might be able find what you're looking for if you just type in the page title Your dev stuff could just open the browser automatically when you start it *.localhost is a Secure Context in Chrome and Firefox
- NoSalt 5mo agoWow ... judging from all of these harsh comments, it seems the flood from Reddit to HN is going "well". I cannot believe all of the negative comments around the development of a piece of handy software.
- llagerlof 5mo agoI mean, it’s the shitty human nature. You can't create anything publicly without people bashing your project, and you, for the sheer insolence of creating a piece of software.
- FactoriumNet 5mo agoI have a strange short-term memory that immediately forgets where I was. I think it just decides I made my decision and no longer needed that trivia clouding the next thought. This is exactly what I have struggled with. Thanks a ton for this!!
- alsetmusic 5mo agoDon't use localhost:3000, use your own custom domain[0] 0. https://idiallo.com/blog/say-no-to-localhost3000-use-custom-domains https://idiallo.com/blog/say-no-to-localhost3000-use-custom-...
- dhruv3006 5mo agoyep - we do need solutions here - nice one.