I created a small library that enables dynamic port allocation for development servers by selecting an available port at runtime.
The main use case is when working on multiple projects at the same time, or when using worktrees and running several versions of the same project in parallel. This has become increasingly common with AI-assisted workflows, where it’s easy to end up working on multiple branches or tasks simultaneously.
While it’s always possible to manually configure different ports for each project, this library removes that friction and lets things work automatically.
After installing the library, you can use it in your runtime config like this:
port_result = DevPortAllocator.resolve_port()
config :my_app, MyAppWeb.Endpoint, http: [port: port_result.port]
This makes it easy to run multiple Phoenix instances locally without worrying about port conflicts.
lib: dev_port_allocator | Hex
docs: DevPortAllocator — dev_port_allocator v0.1.0






















