โ‡ Back to Portfolio

locport – Manage localhost ports

There are many solutions to the problem of running multiple (web) applications on the same machine, during development. You can use various proxies (puma-dev, localcan, traefik, nginx…) and DNS to set up custom hostnames. Which is something I’ve been doing in the past. But there is a more direct and simpler approach.

Modern browsers all support .localhost domains and treat it as a secure context (like it would be served over HTTPS), which is required for things like copy to clipboard from JavaScript. You can freely assign names to you apps, like app1.localhost, app2.localhost, but each one needs a unique port too.

If you have lots of apps, you need to keep track of all these ports and prevent conflicts. This is where locport comes in. It’s a simple command line program. It introduces a .localhost file convention, which you place in each project’s folder and define the hostnames and ports there. locport indexes these files and gives you an overview of all your apps and let’s you know if there are any conflicts.

If you have Ruby installed, you can just:

gem install locport

# Show usage instructions
locport help

Learn more over at GitHub.

โ‡ Back to Portfolio