locport

Overview of localhost ports used across projects. Prevent conflicts.


Keywords
localhost, ports
License
MIT
Install
gem install locport -v 1.1.1

Documentation

locport

Manage local ports across projects. Prevent conflicts. Overview all your projects, hosts and ports.

Inspired by DHH's Rails World 2025 keynote part about how 37Signals deals with serving apps in development.

Rails World 2025 Keynote

Introducing the .localhost file convention

list success

A project can define within it's root, the .localhost file, that lists local hosts with ports that the project uses.

Format of this file is a simple list of <host>:<port> separated by newlines. For example:

hello.localhost:3001
another.service.localhost:3002

A single project can have zero, one or multiple domains associated to it.

To add the project to locport, simply locport index [PATH]. Now you can overview hosts and ports with locport list and easily discover conflicts across any number of projects.

Installation

Ruby is required.

gem install locport

Usage

Adding hosts with ports to a project

To create and/or add to .localhost file, from within your project directory:

locport add <url>[:<port>]

# Example where a unique port is automatically assigned by locport
locport add myapp.localhost

# Example with a user specified port
locport add myapp.localhost:30000

Listing projects and hosts

locport
# OR
locport list

If any conflicts are detected, they will be displayed and program exits with error code 1.

list conflicts

TODOs

  • Check for port and host conflict during add
  • Port generation needs to skip used ports

Development

PRs are welcome. To set up locally from within the checked out repo:

# Install dependencies
bundle

# Run commands with dev code
ruby -Ilib/ bin/locport