ErrorNode.js

Port already in use (EADDRINUSE)

What EADDRINUSE means when Node's server can't bind a port, the most likely reasons it's already taken, and how to free it or pick another one.

Last updated

ErrorNode.js
Error: listen EADDRINUSE: address already in use :::3000
    at Server.setupListenHandle [as _listen2] (node:net:1900:16)

What it means: Node tried to bind a server to a TCP port that's already held by another process, so the listen() call failed outright.

Likely causes

Most probable first — with how to confirm.

  • 1.Another instance of your own app (a previous run, a crashed process, or a second `npm run dev`) is still bound to the port — check with `lsof -i :3000` (macOS/Linux) or `netstat -ano | findstr :3000` (Windows) to see the PID.
  • 2.A different service (another dev server, a database like Postgres on 5432, or a proxy) happens to be using the same port — check the process name behind that PID before killing anything.
  • 3.You restarted the process too quickly, before the OS finished releasing the port from the previous run — this is common with watchers that restart on every save.
  • 4.The port is hardcoded and something else on the machine already owns it permanently, rather than a one-off collision.

Fixes

Safest first; destructive ones are called out.

  • Kill the process holding the port, then restart: `kill -9 $(lsof -t -i:3000)` on macOS/Linux, or find the PID via `netstat -ano | findstr :3000` and `taskkill /PID <pid> /F` on Windows. This ends whatever that process was doing, so confirm it's safe to kill first.
  • Change the port your app listens on (an env var like `PORT=3001`, or the framework's config) if you don't control what else is running on the machine.
  • If it's your own dev server restarting too fast, give the watcher a moment to fully stop the old process before starting a new one.

Related in Errors