Skip to content

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

Closed

Description

@arifszn

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.)

Activity

  1. github-actions commented on Mar 27, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

webRelates to opencode on web / desktop

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions