React project run on localhost:3000.
Then you start a Vite project, and suddenly it's localhost:5173. 🤔
Why such a random number? I finally looked it up, and it's not random at all.
🏢 First, what is a port?
Think of your computer as an apartment building.
| In real life | On your computer |
|---|---|
| The building | localhost (your own machine) |
| A flat number | The port |
| The person living there | Your running app |
So localhost:5173 simply means:
"Go to my building and knock on flat 5173."
🕵️ The secret hidden in 5173
Squint a little and read it like this:
| Number | Letter | Why |
|---|---|---|
| 5 | V | Roman numeral for 5 |
| 1 | I | Looks like I |
| 7 | T | Looks like T |
| 3 | E | A flipped E |
5173 = VITE ⚡
It's like a personalised number plate. At first you see digits, then you spot the name, and you can't unsee it.
🔄 Vite used to live at 3000
Here's the part I didn't know: earlier versions of Vite used port 3000 too.
In Vite 3, the team changed the default to 5173 to move away from such a commonly used port.
Imagine flat 3000 is the most popular flat in the building. Many tools want to move in, but for a given address, only one can live there at a time. So Vite packed its bags and moved to a flat with its own name on it. 📦
Why was 3000 picked in the first place? I couldn't find a confirmed reason.
It's like a popular hangout spot. People keep going there because everyone already knows it.
😵 Why am I seeing 5174?
Sometimes your project opens on 5174 instead.
That means flat 5173 is already occupied, often by another Vite project you left running in a different terminal.
By default, Vite knocks on the next door:
5173 ❌ occupied 5174 ✅ free, moving in! If 5174 is busy too, it keeps looking.
🛠️ Want to choose the port yourself?
In vite.config.js:
import { defineConfig } from 'vite' export default defineConfig({ // keep your existing plugins here server: { port: 3000, strictPort: true, }, }) -
port: the flat you want -
strictPort: true: "This flat or nothing!" Vite stops with an error instead of trying the next one
Or do it just once from the terminal:
npm run dev -- --port 3000 🎯 Quick recap
- 🏢 A port is like a flat number
- ⚡
5173can be read as VITE - 📦 Vite 3 moved the default from
3000to5173 - 🚪
5174usually appears because5173is busy
Happy Coding :)


