Blog
3 min read

EADDRINUSE: Address Already in Use — How to Fix It

"Error: listen EADDRINUSE: address already in use :::3000" means another process is already using that port. How to find which process it is on Mac, Linux and Windows, how to stop it safely, why it keeps happening (old dev servers, nodemon, Docker), and how to make your app pick another port.

You run npm run dev and get:

Error: listen EADDRINUSE: address already in use :::3000

It means another program is already listening on port 3000, and only one process can listen on a given port at a time. Python shows the same problem as OSError: [Errno 98] Address already in use; Docker says "port is already allocated". (Ports Explained)

Nine times out of ten, the "other program" is an old copy of your own app that didn't shut down.

Step 1: Find what's using the port

Mac and Linux:

lsof -nP -iTCP:3000 -sTCP:LISTEN
COMMAND   PID  USER   FD   TYPE  ...  NAME
node    48213  ana    23u  IPv6  ...  *:3000 (LISTEN)

On Linux you can also use:

sudo ss -ltnp | grep :3000

Windows (PowerShell or Command Prompt):

netstat -ano | findstr :3000

The last column is the PID (process ID).

Step 2: Stop it

If it's an old dev server you don't need, stop it by PID:

kill 48213          # Mac/Linux: ask it to stop
kill -9 48213       # only if it ignores the first one
taskkill /PID 48213 /F

(Windows.) Or the one-liner on Mac/Linux:

kill $(lsof -t -iTCP:3000 -sTCP:LISTEN)

Check what it is before killing it. If the process is a database, another project or a system service, pick a different port instead. (Kill a Process in Linux)

Why it keeps happening

  • A dev server in another terminal tab you forgot about.
  • A crashed process that left a child behind — common with nodemon, watch scripts and test runners.
  • Closing the terminal window without stopping the server; on some systems the process keeps running.
  • A Docker container publishing the same port. Check docker ps. (Docker Port Already Allocated)
  • Your app starts its server twice — for example, calling app.listen() in a file that's imported by both your server and your tests.
  • Something else uses the port. On macOS, AirPlay Receiver uses port 5000 (and 7000), which catches out many Flask developers.

Make your app use another port

Most frameworks read the PORT environment variable:

PORT=3001 npm run dev

In your own Node server:

const port = process.env.PORT || 3000
app.listen(port, () => console.log(`Listening on ${port}`))

Vite and Next.js will often offer the next free port automatically. (Environment Variables Explained)

In production

On a server, EADDRINUSE usually means your process manager started a second copy while the first was still running, or two apps are configured with the same port. Let one manager own the app (systemd, PM2 or Docker), give each app its own port, and have the reverse proxy route by domain. (PM2 vs systemd)

The summary

  • Another process is listening on that port — usually your own old dev server.
  • Find the listening process with lsof -nP -iTCP:PORT -sTCP:LISTEN (Mac/Linux) or netstat -ano (Windows), then stop it.
  • Or run your app on a different port with PORT=3001.

EasySpawn manages your app's processes and ports on its server, so a restart never leaves a stale copy behind, and Claude Code can sort out port clashes for you. See how it works or join the waitlist.

Related: What Is Localhost? · ERR_CONNECTION_REFUSED · npm run dev vs build · Terminal for Beginners

Keep reading