The error, verbatim
Jump to the fix ↓node:events:486
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (node:net:1948:16)
at listenInCluster (node:net:2005:12)
at Server.listen (node:net:2110:7)
Tested on
- Node
- 24.14.0
- OS
- Windows 11 Pro
- Shells
- PowerShell 5.1, cmd
Contents
The fix
Another process is already listening on the port. Find its process ID (PID), stop it, then start your server again.
PowerShell:
Get-NetTCPConnection -LocalPort 3000 -State Listen | Select-Object OwningProcess
Stop-Process -Id <PID> -Force
Command Prompt:
netstat -ano | findstr :3000
taskkill /PID <PID> /F
In netstat, the PID is the last number on the LISTENING line:
TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 11156
Check what you’re about to stop
The PID might be a dev server from another project that you still need. Look before you stop it:
Get-Process -Id <PID>
Or just use another port
Most dev servers accept a port flag or a PORT environment variable:
npx next dev -p 3001
npx vite --port 5174
For your own Node server, read the port from the environment so it’s easy to change:
const port = Number(process.env.PORT) || 3000;
server.listen(port);
Why it happens
Only one process can listen on a given port at a time. The usual culprits:
- a dev server still running in another terminal tab or editor window
- a server from a crashed or closed session that’s still running in the background
- two projects that both default to port 3000
What didn’t work
— N.K., end of entry No.003