Vite dev server

localhost:5173

Port 5173 is Vite’s default development port. If the page does not open, first verify the exact Local URL printed by Vite—when 5173 is occupied, Vite normally moves to the next available port.

Tested with Vite 7.xWindows · macOS · Linux · WSL · DockerUpdated September 6, 2026
Default port5173
Default hostlocalhost
Default protocolHTTP
Typical serviceVite

The 60-second check

  1. Read the terminal URL

    Run npm run dev and use the exact URL after Local:. Do not assume it is still 5173.

  2. Confirm that something is listening

    # Windows PowerShell
    Get-NetTCPConnection -LocalPort 5173 -State Listen
    
    # macOS or Linux
    lsof -nP -iTCP:5173 -sTCP:LISTEN
  3. Test without the browser

    curl -I http://127.0.0.1:5173

    An HTTP response means the server is reachable. A refused connection means there is no listener at that address and port.

Match the symptom to the cause

What you seeWhat it usually meansNext check
ERR_CONNECTION_REFUSEDVite stopped, started on a different port, or listens in a different network namespace.Terminal output and the listener command above.
Vite opens on 51745173 was already occupied and Vite selected the next port.Find the existing process or enable strictPort.
ERR_BLOCKED_BY_CLIENTA browser extension or privacy filter blocked the request.Try a clean browser profile, then inspect DevTools.
Works inside WSL or a container onlyThe server is bound to loopback inside that environment, or the port was not published.Bind deliberately and publish the container port.
HTML loads but API calls failThe frontend is reachable; the failing request is a separate API, proxy, CORS, or environment-variable issue.Inspect the failed request in DevTools, then paste its response headers into the CORS Header Analyzer.

Make the port deterministic

Vite’s documented default is 5173, but it tries another port when that port is busy. Use strictPort when scripts, OAuth callbacks, or tests require one fixed origin.

// vite.config.js
import { defineConfig } from 'vite'

export default defineConfig({
  server: {
    port: 5173,
    strictPort: true
  }
})

The CLI equivalent is:

npm run dev -- --port 5173 --strictPort

Port conflict: stop the process already using 5173, or choose a different port. Do not kill a process until you have identified it.

WSL, Docker, and phone access

Vite binds to localhost by default. To accept connections from outside the current environment, bind it to all interfaces:

npm run dev -- --host 0.0.0.0

# Docker example
docker run --rm -p 5173:5173 your-image

Then open http://<computer-lan-ip>:5173 from the other device. In Docker, both the Vite host setting and -p 5173:5173 are required: one controls the listener; the other publishes the container port.

Security: 0.0.0.0 broadens who can reach the development server. Keep it behind a trusted local network and firewall, and do not expose a Vite dev server to the public internet.

The server responds, but it is the wrong page

  • Check the process ID that owns 5173; another project may be running there.
  • Check Vite’s configured base when assets return 404 under a subpath.
  • Check the browser console for a failed module import instead of treating every blank screen as a network failure.
  • If a reverse proxy is involved, test Vite directly first, then test the proxy route.

Official references