feat: Use incremental port assignment (like Vite) instead of random OS-assigned ports #7424

Open
opened 2026-02-16 18:07:07 -05:00 by yindo · 0 comments
Owner

Originally created by @arifszn on GitHub (Jan 24, 2026).

Originally assigned to: @adamdotdevin on GitHub.

Description

When starting multiple OpenCode web servers and the default port 4096 is already in use, the server currently falls back to a random OS-assigned port (e.g., 55651). This makes it difficult to predict which port the server will use.

Expected Behavior

The server should try incremental ports (4096, 4097, 4098, etc.) similar to how Vite handles port conflicts. This provides a predictable port sequence and better developer experience.

Current Behavior

  • First server: Port 4096 ✓
  • Second server: Random port (e.g., 55651) ✗

Proposed Solution

When port is occupied, try incremental ports up to 10 attempts before falling back to OS-assigned port:

  • First server: Port 4096
  • Second server: Port 4097
  • Third server: Port 4098
  • etc.

This should work for both default port (4096) and custom ports specified via --port flag.

Category

Missing standard behavior - improves UX to match common dev server patterns (Vite, Next.js, etc.)

Originally created by @arifszn on GitHub (Jan 24, 2026). Originally assigned to: @adamdotdevin on GitHub. ## Description When starting multiple OpenCode web servers and the default port 4096 is already in use, the server currently falls back to a random OS-assigned port (e.g., 55651). This makes it difficult to predict which port the server will use. ## Expected Behavior The server should try incremental ports (4096, 4097, 4098, etc.) similar to how Vite handles port conflicts. This provides a predictable port sequence and better developer experience. ## Current Behavior - First server: Port 4096 ✓ - Second server: Random port (e.g., 55651) ✗ ## Proposed Solution When port is occupied, try incremental ports up to 10 attempts before falling back to OS-assigned port: - First server: Port 4096 - Second server: Port 4097 - Third server: Port 4098 - etc. This should work for both default port (4096) and custom ports specified via `--port` flag. ## Category Missing standard behavior - improves UX to match common dev server patterns (Vite, Next.js, etc.)
yindo added the web label 2026-02-16 18:07:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7424