Error: listen EADDRINUSE: address already in use :::5000
Quick answer
Another process is already using the port your server is trying to listen on — often a previous `npm run dev` that didn't fully shut down. Kill the process using that port, or change your server's port in `.env`.
What causes this error
Only one process can listen on a given port at a time. This almost always means a previous instance of your server is still running in the background — a terminal you closed without stopping the process, a crashed process that didn't release the port cleanly, or genuinely a different application using the same port.
The Fix
# Find what's using the port (macOS/Linux)
lsof -i :5000
# Kill it by PID
kill -9 <PID>
# On Windows
netstat -ano | findstr :5000
taskkill /PID <PID> /FOr sidestep the conflict entirely by changing your port in .env:
PORT=5001Common causes / variations
- A previous
npm run devprocess still running in another terminal tab - A crashed process (e.g. from an unhandled exception) that didn't release the port on exit
- Genuinely running two different projects that both default to the same port
Related errors
See also: Cannot set headers after they are sent to the client.
Was this fix helpful?
Comments
Loading comments...