Port 3000 Already in Use: Fixes for Windows, Mac, and Linux
The error means another process is already listening on port 3000. Fix it by either killing that process or starting your app on a different port. The commands to find and kill the process differ by operating system, and all of them are listed below.
Fix on Linux
Find the process using port 3000:
lsof -i :3000This shows the process name and PID (process ID). Kill it:
kill -9 <PID>Or do it in one step:
fuser -k 3000/tcpIf lsof is not installed (common on minimal server images), use ss instead:
ss -tlnp | grep 3000Fix on macOS
The commands are the same as Linux. macOS ships with lsof:
lsof -i :3000
kill -9 <PID>On macOS Monterey and later, the AirPlay Receiver service sometimes grabs port 5000. If your app uses port 5000 and you see this conflict, disable AirPlay Receiver in System Settings > General > AirDrop & Handoff.
Fix on Windows
Open Command Prompt or PowerShell as Administrator.
Find the process:
netstat -ano | findstr :3000The last column is the PID. Kill it:
taskkill /PID <PID> /FIn PowerShell, you can also use:
Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess | Stop-Process -ForceAlternative: Use a different port
If you do not want to kill the existing process, start your app on a different port instead.
Next.js:
npx next dev -p 3001Or set it in your package.json scripts:
"dev": "next dev -p 3001"Express:
const PORT = process.env.PORT || 3001;
app.listen(PORT);Vite:
npx vite --port 3001Django:
python manage.py runserver 3001Using an environment variable for the port (process.env.PORT) is the most flexible approach because deployment platforms set this variable automatically.
Preventing the problem
The most common cause is a previous dev server that did not shut down cleanly. If you close a terminal window without stopping the server (Ctrl+C), the process keeps running in the background.
Good habits:
- Always stop servers with Ctrl+C before closing the terminal.
- If your dev server crashes, check if it left a zombie process before restarting.
- Some frameworks (Next.js, Vite) detect the port conflict and offer to use the next available port automatically. Accept the prompt when it appears.
Frequently Asked Questions
- What does EADDRINUSE mean?
- EADDRINUSE is a system error code that stands for "Error: Address In Use". It means the port number your application is trying to bind to is already taken by another process on your machine.
- Can two apps share the same port?
- No. Only one process can listen on a given TCP port at a time. If you need to run multiple apps locally, give each one a different port: 3000, 3001, 3002, and so on.
- I killed the process but the error persists. What now?
- The port might be in a TIME_WAIT state, which means the OS is holding it for a few seconds after the process exits. Wait 30 seconds and try again. If it still persists, check for multiple processes on the port or restart your machine.
Ready to build real-world apps?
Join the McTaba Labs full-stack marathon. Ship 8 production apps with M-Pesa, USSD, and WhatsApp integrations, and get career support until placement.
See Programs