Node.js EADDRINUSE “address already in use”: free the port
Find the process holding the port with lsof, stop it, or move your server to a free port.
Something already owns the port. Run lsof -i :3000 to find the PID, stop that process, or start your server on another port with the PORT environment variable.
Try these fixes in order
Find what holds the port
Identify the process on the port. On macOS or Linux use lsof -i :3000; on Windows use netstat -ano | findstr :3000 and match the PID in Task Manager.
lsof -i :3000Stop the stale process
If it is a stale instance of your own server, stop it with kill <PID>. Only then rerun your server on the same port.
kill <PID>Or move to a free port
If the port belongs to something you should not kill, start your server on another port, for example PORT=3001 node server.js, and update the client or proxy config to match.
PORT=3001 node server.jsHandle the error gracefully in code
In code, listen for the server 'error' event and check err.code === 'EADDRINUSE' to print a clear message ("port in use, is another instance running?") instead of an unhandled crash.
Interpret what you see
The error names a specific port your server tried to bind
What it suggests: The port in the error is occupied by a live process. The :::3000 form means all IPv6/IPv4 interfaces on port 3000.
Next check: Run lsof -i :3000 (macOS/Linux) to print the PID and command holding the port.
lsof shows your own server command on the port
What it suggests: A previous run of your own server survived a terminal close or a crashed watcher and still owns the port.
Next check: Run ps aux | grep node and look for duplicate server processes.
lsof shows a process you do not recognize
What it suggests: The port is taken by an unrelated service (database admin UI, another project, system service).
Next check: Check the COMMAND column of lsof; if it is not your app, pick a different port instead of killing it.
Why this happens
- Another process already holds the port, often a previous instance of the same server that was not stopped.
- Two development processes were started at once, for example node and nodemon, or two terminal tabs.
Still not working?
Do not reach for kill -9 as the first move on a shared machine; identify the process before terminating it. And do not silence the error by catching it and continuing without a listening server — the app would run with no port bound.
Official sources
These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.