Home / Localhost / localhost:5173

localhost:5173 (Vite): not working and fixes

Port 5173 is Vite’s default. How to open it, change the port and fix connection problems.

Open this address: http://localhost:5173This opens on your own computer. It only works if the program is running.

localhost:5173 is where the Vite development server runs by default. If the page does not load, check the terminal, because Vite prints the exact address it is using.

localhost:5173 in a browser address bar reaches port 5173 on your computer, where Vite dev server is running

What runs on localhost:5173

Commands to start and test port 5173

Start Vite
npm run dev
Use another port
npm run dev -- --port 5174
Allow phones and other computers
npm run dev -- --host

Find what is using port 5173

Run these in a terminal on your computer. Nothing is sent to this site.

If localhost:5173 will not open

Vite shows “Blocked request. This host is not allowed”
Since Vite 6, the dev server answers only to host names in server.allowedHosts. localhost, .localhost subdomains and IP addresses are allowed by default. Behind a tunnel or a custom host name, add it to server.allowedHosts. Vite warns that setting it to true allows any host and is unsafe because of DNS rebinding.
Fail instead of switching to another port
If 5173 is busy, Vite uses the next free port. Set server.strictPort: true to make it exit instead, which helps when other tools expect exactly 5173.
The default address is localhost only
server.host defaults to localhost. --host or server.host: true listens on every address, including your LAN. That is what you need for a phone or a container, but it also exposes the server to other devices.
Changes do not reload on WSL2
When you edit files from Windows, WSL2 can miss the change. Vite’s docs suggest server.watch: { usePolling: true } as a workaround. It uses more CPU.
Calling an API gives a CORS error
Use server.proxy to forward a path such as /api to your back end, so the browser talks only to the Vite server.
vite preview is on a different port
vite preview serves the built site on its own port, 4173 by default, not on 5173. Read the address in the terminal.
Vite started on 5174, not 5173
Port 5173 was busy, so Vite picked the next free one. Open the exact address printed in the terminal.
localhost refuses to connect but 127.0.0.1 works
Newer Node versions can resolve localhost to IPv6 (::1). Open http://127.0.0.1:5173 or set server.host to "127.0.0.1" in vite.config.
Cannot open it from another device
Add --host and use your computer’s IP address. See how to open localhost from your phone.
npm run dev: missing script
Your package.json has no dev script. Check the scripts section, or you are in the wrong folder.

Other ports like 5173

PortUsually used by
localhost:3000React, Next.js, Express
localhost:4200Angular dev server
localhost:5000Flask
localhost:8000Django, PHP, Python
localhost:8080Tomcat, Spring Boot, Docker
localhost:8888Jupyter Notebook
localhost:9000PHP-FPM, SonarQube

Questions about localhost:5173

What is port 5173?
It is the default port of Vite, the build tool behind many React, Vue and Svelte projects.
Why did Vite use 5174 instead?
Port 5173 was busy, so Vite moved to the next free port. Open the address printed in the terminal.

Updated 2026-10-20

Free tools that help

Related pages