Dev Port Registry for Multi-Project Work

A centralized port assignment table in shared developer config prevents localhost collisions when running multiple projects simultaneously.

Tags

Dev Port Registry for Multi-Project Work

The Lesson

When a developer works across multiple projects that each run local dev servers, port collisions are inevitable unless ports are assigned centrally. A simple table in shared config — not in each project's individual settings — is the cheapest way to prevent "address already in use" errors and the debugging they trigger.

Context

A single developer maintains seven active projects (lessons, JobClass, Certification, Artemis, portal, mdreader, epstein), each with an Astro or Vite frontend dev server and most with a FastAPI backend. During active development, two or three of these run simultaneously — for example, the lessons hub frontend plus a source project's dev server to test harvesting behavior. Each framework defaults to a well-known port (Astro: 4321, Vite: 5173, FastAPI/Uvicorn: 8000), creating guaranteed collisions.

What Happened

  1. Initially, each project used its framework's default port. Running two Astro projects simultaneously required manually passing --port flags or killing the first server.
  2. Some projects had their ports configured in astro.config.mjs or uvicorn launch scripts, but the assignments were made independently — no single source of truth existed for which port belonged to which project.
  3. A port collision during a cross-project test session (lessons hub trying to fetch from a source project's dev server) wasted 20 minutes of debugging before the developer realized both were fighting over port 4321.
  4. A port registry was added to a global developer configuration file (a markdown file that AI assistants and developer tools read at the start of every session) as a simple table mapping each project to a frontend port (4331–4337) and a backend port (8011–8017). The range was chosen to avoid conflicts with common defaults (3000, 4321, 5173, 8000, 8080). The same table could live in a team wiki, a shared dotfile, or any other location that's checked before spinning up a dev server.
  5. Each project's config was updated to use its assigned ports. The global table ensures that any new project gets the next available slot, and any tool (including AI assistants) configuring a dev server knows which port to use.

Key Insights

Examples

Port registry table:

Project Frontend Backend
lessons 4331 8011
JobClass 4332 8012
Certification 4333 8013
Artemis 4334 8014
portal 4335 8015
mdreader 4336 — (static only)
epstein 4337 8017

Next available: frontend 4338, backend 8018.

Applicability

This pattern applies whenever one developer (or team on shared machines) runs multiple local services. It scales to ~50 projects before the table becomes unwieldy. Beyond that, consider a port allocation service or Docker Compose with service discovery.

It does NOT apply to:

Related Lessons

Related Lessons