The EADDRINUSE error occurs when you try to start a Node.js server on a port that is already in use by another process. This typically happens when a previous server instance wasn't properly closed or another application is using the same port.
EADDRINUSE is a system-level error (Address already in use) that Node.js raises when attempting to bind to a specific port. This means the operating system has already assigned that port to another process. The error prevents your Node.js application from listening for connections because the port is occupied. Common scenarios include a crashed server process still holding the port, another application already using it, or pressing Ctrl+Z instead of Ctrl+C which leaves the process running in the background.
Use the kill-port npm package, which works on all platforms:
npx kill-port 3000Replace 3000 with your actual port number. You can also kill multiple ports at once:
npx kill-port 3000 5000 8080This is the easiest and most reliable method.
If you prefer not to use a third-party package, find the process ID (PID) first:
lsof -i :3000This will show you which process is using port 3000. Look for the PID column, then terminate the process:
kill -9 <PID>Alternatively, use fuser for a one-command solution:
sudo fuser -k 3000/tcpOpen Command Prompt as Administrator and run:
netstat -ano | findstr :3000This shows the process using port 3000. Note the PID in the rightmost column, then kill it:
taskkill /PID <PID> /FAlternatively, kill all Node processes:
taskkill /F /IM node.exeNote: This will kill ALL Node processes, not just the one using the port.
Always use Ctrl+C to stop Node servers, never use Ctrl+Z. Ctrl+Z suspends the process in the background without actually terminating it.
After killing the process, verify the port is now free:
lsof -i :3000If nothing is returned, the port is free. Now restart your server:
npm startIf the above steps don't work or the port is being used by another service, configure your app to use a different port:
const port = process.env.PORT || 3001;
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});Then start with:
PORT=3001 npm startOn macOS Monterey (version 12) and later, AirPlay automatically uses ports 5000 and 7000. If your development server uses port 5000, disable AirPlay Receiver in System Preferences > Sharing to free up the port. Older versions of nodemon (before 2.0.14) had issues with EADDRINUSE errors; update nodemon if you experience persistent issues.
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error