Next.js or Vite started on port 3001? Here's why
Updated · 2 min read
When their port is taken, Next.js and Vite don't stop. They move to the next free one and say so in a line that's easy to miss:
⚠ Port 3000 is in use by process 48213, using available port 3001 instead.Port 5173 is in use, trying another one...Your old browser tab still shows whatever answers on 3000: often yesterday's server with yesterday's code.
Find what's on the old port
lsof -nP -iTCP:3000 -sTCP:LISTENUsually it's an earlier npm run dev that kept running after its terminal tab was closed. Stop it with kill and the number from the PID column, then start again. More in Port already in use on Mac.
Make it fail instead of moving
A server that stops with an error is easier to notice than one that quietly moved.
Next.js only moves when you didn't choose the port. Give it one, and a taken port stops it with Failed to start server and EADDRINUSE:
next dev -p 3000PORT=3000 next dev works the same way.
Vite (and SvelteKit, which uses the same config file) takes strictPort:
// vite.config.js
export default {
server: { port: 5173, strictPort: true },
}; With it, a taken port stops Vite with Port 5173 is already in use.
Why it keeps happening
Projects share a handful of default ports: 3000, 5173, 8000, 8080. Open two or three at once and they compete for them, so each lands wherever there's room. Giving every project a port of its own ends it.
How Portroom handles it
A port of its own for every project
Portroom gives each project its own port and passes it to the server: as -p for Next.js, as --port for Vite, Astro and SvelteKit, and as PORT for everything. A Fixed port never moves by itself; when it’s taken, the project says by what and offers the next free one.
With Pretty URLs you open shop.localhost instead of a port, and the address stays the same whatever port the server got.


Something wrong or out of date on this page? Write to support@portroom.dev.