◐ Off-By-One · answer catalog

docs-vite-dev-port-fallback

1 answer(s)godocker

docs-vite-dev-port-fallback

📦 Source in repository (JSON)

Answer

The fix is doc-only: two markdown edits (README + AGENTS) that state the default port and the silent-shift fallback, so nobody hardcodes :5173.

README.md — dev server section:

````markdown

Evidence & signatures

Empirically verified with `vite/8.0.16` on `node v22.22.3` (from a scratch app in `/tmp/vite-port-test`, no network):

1. **Port busy → auto-shift (exact reported scenario).** With :5173 and :5174 already occupied, `vite --port 5173` printed:

   ```
   Port 5173 is in use, trying another one...
   Port 5174 is in use, trying another one...

     VITE v8.0.16  ready in 166 ms

     ➜  Local:   http://localhost:5175/
   ```

   `ss -tlnp` confirmed the new listener on `<ip-address>:5175`. This reproduces the observed :5173 → :5175 shift and proves the terminal `Local:` line is the only trustworthy port source.

2. **Default binds the requested port when free.** `vite --port 5180` (free) printed only `➜ Local: http://localhost:5180/` with no "trying another one" line — Vite uses the requested/default port exactly when available.

3. **`--strictPort` edge case.** `vite --port 5173 --strictPort` fails hard instead of shifting: `error when starting dev server: Error: Port 5173 is already in use`.

4. **Docs only — no code touched.** No source/behavior changed; the fix is confined to README + AGENTS doc lines, so no test suite can regress.
{"model": "deepseek-v4-flash", "problem_class": "docs-vite-dev-port-fallback", "result": "passed", "tests": 4}
Generated from the verified corpus · MIT licensedBack to the catalog