port 5173 · vite dev server

localhost:5173

Port 5173 is where the Vite dev server listens by default. It lives on your own machine, not on the internet. If you got here by typing localhost5173 into the address bar, this is the link you actually wanted:

Only opens if a dev server is running on this device right now. Remove the autocomplete that sent you here →

Server runs but something is off? The usual suspects →

~/your-project — npm run dev
$ npm run dev

  VITE v8.2.2  ready in 312 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

# troubleshooting

Why localhost:5173 is not opening

Eight things that go wrong, from the most common down. Each one with the command that fixes it.

  1. ERR_CONNECTION_REFUSED — “This site can’t be reached”

    Nothing is listening on 5173. Nine times out of ten the dev server is simply not running.

    bash
    cd your-project
    npm install
    npm run dev
  2. You typed localhost5173 and landed here

    Without the colon the browser treats it as a search term, so a search engine answered instead of your machine. The address needs the colon.

    address bar
    http://localhost:5173
  3. “Port 5173 is in use, trying another one…”

    Another dev server — usually one you forgot to stop — holds the port, so Vite quietly moves to 5174, 5175, and so on. Either open the port it printed, or free 5173.

    bash
    # macOS / Linux
    kill -9 $(lsof -ti:5173)
    
    # Windows
    netstat -ano | findstr :5173
    taskkill /PID <pid> /F
    
    # either
    npx kill-port 5173
  4. Works on your laptop, not on your phone

    localhost always means “this device”. On the phone it points at the phone, where nothing is running. Expose the server and open the Network URL Vite prints.

    bash
    npm run dev -- --host
    # ➜ Network: http://192.168.x.x:5173/
  5. Dead inside Docker, WSL or a codespace

    The server binds to 127.0.0.1 inside the container, which the host cannot see. Bind to every interface and publish the port.

    bash
    vite --host 0.0.0.0
    docker run -p 5173:5173 my-image
  6. https://localhost:5173 does not load

    The dev server speaks plain HTTP. The s makes the browser wait for a TLS handshake that never comes. Drop it, or add a dev certificate.

    address bar
    http://localhost:5173
    # TLS in dev:
    npm i -D @vitejs/plugin-basic-ssl
  7. You want a port other than 5173

    Two projects fighting over one port, a firewall rule, a proxy expecting something fixed. strictPort makes Vite fail loudly instead of silently sliding to 5174.

    vite.config.js
    // vite.config.js
    export default defineConfig({
      server: { port: 3000, strictPort: true }
    })
    
    # or once:
    npm run dev -- --port 3000

# dev server

When the server runs but something is off

Everything that goes wrong between npm run dev and a working page, sorted by where it goes wrong — each with the current option, not the one that was current in 2023.

Reaching the Vite dev server from anything other than localhost

The Vite dev server binds to localhost only and rejects unknown hostnames, so a second device, a container or a tunnel needs two separate settings: server.host to bind wider, and server.allowedHosts to accept the name being used.

  • Blocked request. This host is not allowed.The Vite dev server only answers to localhost, hostnames ending in .localhost, and IP addresses — every other hostname has to be listed in server.allowedHosts.
  • Reaching localhost:5173 from your phone or another machineThe dev server listens on localhost by default, so nothing else on the network can reach it — start it with --host (or set server.host) to listen on your LAN address.
  • Running the Vite dev server in a containerInside a container localhost means the container, so the dev server has to listen on 0.0.0.0 and the port has to be published — mapping the port alone is not enough.
  • Running the Vite dev server over HTTPSserver.https takes the options object Node’s https.createServer() expects, so it needs an actual certificate — setting it to true does not generate one for you.
  • https://localhost:5173 does not loadUnless server.https is set, the Vite dev server on port 5173 speaks plain HTTP only, so a browser that opens https://localhost:5173 sends a TLS handshake to an HTTP server and fails with ERR_SSL_PROTOCOL_ERROR — use http://localhost:5173 or enable TLS.
  • Reaching localhost:5173 from Windows when Vite runs in WSL2WSL2 forwards localhost to Windows for you, so a Windows browser normally opens localhost:5173 without --host — but reaching the same server from another machine on your LAN is a Windows-side networking change, not a Vite setting.
  • Exposing localhost:5173 through ngrok or a Cloudflare tunnelA tunnel agent runs on your own machine and connects to 127.0.0.1:5173, so the default bind is already enough — what stops the first request is server.allowedHosts, which rejects the generated tunnel hostname.
  • What the address block Vite prints on localhost:5173 tells youThe Local line is the address that only works on this machine, the Network lines are the ones another device can open — and "Network: use --host to expose" means Vite found no network address to print because the server is bound to loopback only.

How the Vite dev server handles requests to and from localhost:5173

Three settings cover three different requests: server.proxy forwards a request from 5173 to your backend, server.cors decides which origins may read a response from 5173, and server.allowedHosts decides which hostnames may reach 5173 at all.

  • Proxying API requests from the Vite dev serverserver.proxy forwards any request whose path starts with a given prefix to another server, so the browser only ever talks to localhost:5173 and no CORS error appears.
  • CORS errors around localhost:5173The Vite dev server only accepts cross-origin requests from localhost, 127.0.0.1 and ::1 by default — anything else has to be allowed explicitly, and setting cors to true opens it to every website.
  • Rewriting the path when the Vite proxy forwards a requestrewrite is called with req.url — the full path including the query string — and whatever it returns replaces req.url before the request is forwarded, so it has to come back as a path that still starts with a slash.
  • Proxying WebSocket connections through the Vite dev serverA WebSocket through the dev server needs ws: true (or a target starting with ws:// or wss://) on its proxy entry, because upgrade requests are handled by a separate listener that ignores every rule without one.
  • When the Vite proxy does not forward the requestA proxy that appears to do nothing has either never seen the request — because the browser addressed the backend directly, or because a middleware ahead of it answered first — or it saw it and no key matched, and DEBUG=vite:proxy tells the two apart in one line.

What happens between npm run dev and the page on localhost:5173

Starting the Vite dev server takes five steps: npm resolves the vite binary, Vite reads the config, dependencies are pre-bundled, the server listens on 5173, and the browser opens an HMR WebSocket on the first request.

  • When npm run dev does not bring up localhost:5173Read the terminal before the browser: npm run dev fails at one of four points — a missing script, a missing binary, a config error, or a port that is not the one you are opening.
  • Dependency pre-bundling on the Vite dev serverVite converts your dependencies to ESM once before serving them on 5173 and caches the result in node_modules/.vite — optimizeDeps controls what goes into that step and what stays out of it.
  • Hot Module Replacement on localhost:5173HMR swaps a changed module in the running page over a WebSocket instead of reloading it; when that WebSocket cannot connect, Vite falls back to full page reloads or stops updating at all.
  • Clearing the Vite dependency cacheVite caches pre-bundled dependencies in node_modules/.vite — delete that directory or start with --force to rebuild it.
  • localhost:5173 loads but the page stays blankA blank page on localhost:5173 is a dev-server problem only if the document request itself fails — a 404 with an empty body means Vite found no index.html in the project root — while a 200 with an empty page means a script failed in the browser, which Vite does not show in the terminal by default.
  • vite: command not found / 'vite' is not recognizedThe shell cannot find the vite binary: either the vite package is not in node_modules of this project, or it is installed and you typed vite outside an npm script, where node_modules/.bin is not on the PATH.

The port itself

This page is the hub for the port — these two go deeper.

  • Changing the port the Vite dev server usesSet server.port in vite.config.js, or pass --port on the command line; add strictPort: true if you want Vite to fail instead of silently moving to the next free port.
  • Port 4173: vite preview, not the dev servervite preview serves the finished build from dist/ on port 4173, while the dev server on 5173 compiles your source on the fly — they are two different servers with two different ports.
  • Finding and freeing whatever is holding port 5173Run lsof -nP -iTCP:5173 -sTCP:LISTEN on macOS or Linux, netstat -ano | findstr :5173 on Windows, to get the PID holding the port, then kill it — or leave it alone and read the port Vite printed instead, because without strictPort Vite has already moved on.
  • Making the Vite dev server open localhost:5173 in the browser automaticallyVite does not open a browser by default — set server.open to true in vite.config.js or start the server with --open, and pick the browser with the BROWSER environment variable rather than with the option itself.
  • localhost:5173 vs 127.0.0.1:5173By default the Vite dev server listens on exactly one loopback address — whichever one localhost resolves to first — and on current Node that is often ::1, so http://127.0.0.1:5173 is refused while http://localhost:5173 answers.

Every server option that changes what localhost:5173 does

Everything the dev server on localhost:5173 does is configured under the server key in vite.config.js — twenty options, of which only host, port, strictPort, open and cors have a CLI flag; the rest exist in the config file only.

  • What changed for the Vite dev server in Vite 5, 6, 7 and 8The change most likely to break a dev server on localhost:5173 did not arrive with a major version: Vite 4.5.6, 5.4.12 and 6.0.9, all released on 20 January 2025, added the host check behind server.allowedHosts and switched server.cors off by default.
  • vite.config.js or a CLI flag — which one wins on port 5173A CLI flag such as --port overrides the same option in vite.config.js, but a plugin that sets the option in its config hook overrides both, because Vite merges plugin results after the command line.
  • How every claim on this site is verifiedEvery page here is checked against one named Vite release — 8.3.0, published 2026-09-10 — in three places in a fixed order: the documentation, the source at that release tag, and a local reproduction, and the date of that check is printed at the foot of the page.
  • What this site does not answerThis site answers one subject — the Vite dev server listening on localhost:5173 — so production builds, environment variables, plugin authoring, framework wrappers and other ports as a subject of their own are left to the Vite documentation and to the projects that own them.

# autocomplete

Get rid of the suggestion that sent you here

Once you have opened this domain, your browser remembers it and offers it the next time you type localhost. One keystroke removes the entry — the suggestion list is just your history.

  • Chrome, Edge, Brave, Arc

    Shift + Delete

    Start typing until the wrong entry appears, press ↓ to highlight it, then Shift + Delete. On a Mac keyboard without a Delete key: Shift + Fn + Backspace.

  • Firefox

    Shift + Delete

    Same handling: highlight the suggestion with ↓, then Shift + Delete removes it from the address bar history.

  • Safari

    via History

    Safari has no shortcut for a single suggestion. Open History (⌘ Y), search for localhost, select the entries and press Backspace.

  • Phones and tablets

    via History

    The suggestion is fed from your browsing history. Delete the localhost entries there and it stops appearing.

Afterwards, type the address with the colon — or better, bookmark it. The omnibox learns from what you actually pick.

address bar
# wrong — the browser searches for this
localhost5173

# right — the colon makes it an address
http://localhost:5173

# who uses port 5173

Vite — and everything built on it

Vite 3 made 5173 the default in 2022. Every framework that uses Vite for development inherited it, which is why the number shows up in so many terminals, tutorials and bug reports.

  • Vite

    Every template — vanilla, React, Vue, Svelte, Solid, Preact, Lit — starts here on npm run dev.

  • SvelteKit

    Built on Vite, so vite dev opens the same port.

  • React Router v7 / Remix

    Its Vite-powered dev server uses 5173 too.

  • Qwik

    Qwik City runs on Vite, and therefore on 5173.

  • Laravel + Vite

    The Vite plugin serves assets from 5173 while PHP answers on 8000.

  • A screenshot

    Tutorials, bug reports and screen recordings are full of localhost:5173 links. They only ever worked on the machine that recorded them.

# the neighbourhood

Default ports you will meet next to 5173

PortToolNote
5173Vite Default dev server port since Vite 3 (2022)Default dev server port since Vite 3 (2022)
5174+Vite, fallback Taken automatically when 5173 is busyTaken automatically when 5173 is busy
4173vite preview Serves the production build from dist/Serves the production build from dist/
3000Next.js · Nuxt · CRA Also the old Vite 2 defaultAlso the old Vite 2 default
8080Vue CLI · webpack-dev-server The classic pre-Vite front-end portThe classic pre-Vite front-end port
4200Angular CLI ng serveng serve
4321Astro Vite-based, but its own portVite-based, but its own port
6006Storybook Unchanged even with the Vite builderUnchanged even with the Vite builder
1420Tauri Runs its Vite server on a separate portRuns its Vite server on a separate port
8000Django · php artisan serve Backend half of many 5173 setupsBackend half of many 5173 setups

# trivia

Why 5173 of all numbers?

Vite 2 started on port 3000 — and so did Next.js, Nuxt, Create React App and roughly every Node backend ever written. Vite 3 moved out of that traffic jam in 2022 and picked something nobody else was using. Fewer collisions, fewer “port already in use” messages on the first run of the day.

The number itself has a second reading that the community likes better: 5173 spells SITE in leetspeak.

leetspeak
5 → S
1 → I
7 → T
3 → E

Take that part as folklore rather than documentation. The practical reason — getting away from the crowded 3000 — is the one that mattered.

# faq

Questions about port 5173

What is localhost:5173?

It is the address of a Vite development server running on your own computer. localhost points at your machine, 5173 is the port Vite listens on by default. It is not a public website — it exists only while a dev server is running on that one device.

Why does localhost:5173 refuse to connect?

Because nothing is listening on that port. Run npm run dev inside your project folder and open the URL the terminal prints. If Vite reports that 5173 is in use, it has moved to 5174 or higher.

Which programs use port 5173?

Vite and everything built on it: SvelteKit, React Router v7 (formerly Remix), Qwik, the Laravel Vite plugin, and every Vite starter template for React, Vue, Svelte, Solid, Preact or vanilla JavaScript.

Is localhost:5173 safe?

Yes. Traffic to localhost never leaves your computer. It becomes reachable for others only if you start the server with --host on a shared network or open a tunnel to it deliberately.

Why 5173 and not 3000?

Vite 3 moved the default off 3000 in 2022 because that port was already crowded by Next.js, Nuxt, Create React App and countless Node backends. A rarely used port means fewer collisions. The number also reads as SITE in leetspeak — 5=S, 1=I, 7=T, 3=E — which is how the community likes to explain it.

What is the difference between 5173 and 4173?

5173 serves your source files with hot module replacement while you develop. 4173 is what vite preview uses to serve the built bundle from dist/, so you can check the real production output before deploying.

Can I open someone else’s localhost:5173?

No. The name resolves to 127.0.0.1 on whatever device you open it on, so you always reach your own machine. Sharing a running dev server needs a tunnel such as cloudflared or localtunnel, or a deployed preview URL.

Is this site affiliated with Vite?

No. localhost-5173.com is an independent explainer for a port number. Vite is an open source project maintained by VoidZero and its contributors; the official documentation lives at vite.dev.