Port Already In Use — Fixing EADDRINUSE
Troubleshooting / port-already-in-use.html
Why the server dies with 'address already in use', and how to find and clear the process holding the port.
💬 Symptom: Error: listen EADDRINUSE :::3000
A previously started server still holds the port, or another program is already using it.
Cause
- A previous process never exited.
- Another service (DB, other app) uses the same port.
Diagnose
# macOS / Linux
lsof -i :3000
# PID only
lsof -ti :3000
Fix
# kill the process
kill -9 $(lsof -ti :3000)
# or run on another port
PORT=3001 npm run dev
Verify the fix
- Running
lsof -i :3000again and getting nothing means it's clear. - Restart the server and confirm it boots.
Sources
- stackoverflow SO 9893645 — Canonical question
- Official docs Node.js errors — Official docs
Verified date indicates freshness. Check applicability conditions for older material.