EADDRINUSE: address already in use
Another program is already listening on the port your server wants, often an old copy of the same dev server that never stopped.
Also appears as
- Error: listen EADDRINUSE: address already in use 127.0.0.1:3000
- error when starting dev server: Error: Port 5173 is already in use
- ⚠ Port 3000 is in use by process 48213, using available port 3001 instead.
Prompt to fix it
Starting the dev server fails with "Error: listen EADDRINUSE: address already in use" on a port. Find which process holds that port (lsof -i :PORT on macOS or Linux, netstat -ano on Windows) and tell me what it is before stopping anything. If it’s an old copy of this app’s dev server, stop it and restart. If two of our own servers share the port, give each its own port and update the URLs, CORS settings, and auth redirect URLs that depend on it. Don’t kill processes you can’t identify.
Paste into Layerwise or any AI coding tool.
What it means
A port is a numbered door on your computer, and only one server at a time can listen on each. Dev servers use fixed ones: 3000 for Next.js and many Node servers, 5173 for Vite. EADDRINUSE stands for “address in use”: something already holds that port, so your server couldn’t start. The :::3000 at the end means port 3000 on every network address.
Usually the other program is your own app. A dev server started in another terminal tab, an editor, or an AI tool’s background task keeps running after you stop looking at it. A crashed npm run dev can also leave a child process behind that still holds the port.
Some tools hide this by moving to the next free port. next dev switches to 3001 and Vite to 5174 with a one-line notice. The app loads, but sign-in redirects, OAuth callback URLs, and CORS rules set up for the old port break in confusing ways. Free the original port and keep using it.
Common causes
- A previous
npm run devis still running in another terminal, editor window, or background task. - A crashed or force-closed dev server left a child process that still holds the port.
- Two parts of the app, like a frontend and an API server, are both set to the same port.
- Another app on your machine uses that port, such as AirPlay Receiver on port
5000on macOS.
How to fix it
- Find what holds the port. On macOS or Linux, run
lsof -i :3000. On Windows, runnetstat -ano | findstr :3000. - If it’s an old dev server, go to its terminal and press Ctrl+C. Otherwise stop it by process ID with
kill <PID>on macOS or Linux, ortaskkill /PID <PID> /Fon Windows. - Start your server again with
npm run dev. - If two of your own servers need to run together, give each its own port, for example
PORT=3001for the API, and update every URL that points at it. - To make Vite stop with an error when its port is busy, set
server.portto5173andserver.strictPorttotrueinvite.config.ts.
Example fix
# macOS or Linux: see what holds port 3000, then stop it by PID.
lsof -i :3000
kill 48213
# Windows
netstat -ano | findstr :3000
taskkill /PID 48213 /FRelated errors
All errorsnet::ERR_CONNECTION_REFUSED
Nothing was listening at that address and port, usually because the server isn’t running or the app is calling the wrong port.
Blocked by CORS policy
The browser hid a response from another site because that server never said your site is allowed to read it.
Error 400: redirect_uri_mismatch
Google stopped the sign-in because the return address your app sent isn’t on the OAuth client’s list of approved redirect URIs.
Cannot find module
Node tried to load a package or file that isn’t where the code says it is, usually because it was never installed or the path is wrong.
Build with an agent that checks its work
The Layerwise agent clicks through the live preview and reads the console, so it catches errors before you do.