Getting the "npm ERR! code EADDRINUSE" error when running npm start or npm run dev? This comprehensive guide shows you how to find and kill the process occupying your port on Windows, macOS, and Linux.
npm ERR! code EADDRINUSE npm ERR! errno EADDRINUSE npm ERR! syscall listen npm ERR! Error: listen EADDRINUSE: address already in use :::3000 npm ERR! at Server.setupListenHandle [as _listen2] (net.js:1318:16) npm ERR! at listenInCluster (net.js:1366:12) npm ERR! at Server.listen (net.js:1452:7)
? Something is already running on port 3000. Would you like to run the app on another port instead? (Y/n)
Error: listen EADDRINUSE: address already in use 0.0.0.0:8080
at Server.setupListenHandle [as _listen2] (net.js:1318:16)
at listenInCluster (net.js:1366:12)
at doListen (net.js:1505:7)
Emitted 'error' event on Server instance
The Problem: The port (e.g., 3000, 5000, 8080) is already in use by another process
Solution: Find and kill the process using that port
netstat -ano | findstr :3000taskkill /PID <PID> /Fnpm start againlsof -ti:3000 | xargs kill -9npm start againlsof -ti:3000 | xargs kill -9npm start againEADDRINUSE = "Error: Address Already in Use"
This error occurs when:
# Find process using port 3000 (replace 3000 with your port) netstat -ano | findstr :3000 # Output will look like: # TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 12345 # The last number (12345) is the Process ID (PID)
# Find process with more details Get-NetTCPConnection -LocalPort 3000 | Select-Object -Property LocalPort, OwningProcess, State # See process name Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess
# Find process using port 3000 lsof -i :3000 # Output shows: # COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME # node 12345 user 21u IPv6 0x... 0t0 TCP *:3000 (LISTEN) # More detailed view with process name lsof -i :3000 | grep LISTEN
# Method 1: Using lsof (most common) lsof -i :3000 # Method 2: Using netstat netstat -tulpn | grep :3000 # Method 3: Using ss (modern replacement for netstat) ss -tulpn | grep :3000 # Method 4: Using fuser fuser 3000/tcp
# Replace 12345 with the PID from step 2 taskkill /PID 12345 /F # /F = Force kill # You should see: SUCCESS: The process with PID 12345 has been terminated.
# Find and kill in one command (port 3000)
Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess | Stop-Process -Force
# For multiple ports
@(3000, 5000, 8080) | ForEach-Object {
Get-Process -Id (Get-NetTCPConnection -LocalPort $_).OwningProcess -ErrorAction SilentlyContinue | Stop-Process -Force
}
# Method 1: Kill by PID (get PID from lsof command) kill -9 12345 # Method 2: One-liner - Find and kill lsof -ti:3000 | xargs kill -9 # Method 3: More graceful kill (try this first) lsof -ti:3000 | xargs kill # Method 4: Using sudo if permission denied sudo lsof -ti:3000 | xargs sudo kill -9
kill -9 is a force kill (SIGKILL). Try regular kill (SIGTERM) first for graceful shutdown.
# Method 1: Using kill with PID kill -9 12345 # Method 2: One-liner with lsof lsof -ti:3000 | xargs kill -9 # Method 3: Using fuser fuser -k 3000/tcp # Method 4: Using pkill (kill by process name) pkill -f "node.*3000" # With sudo if needed sudo fuser -k 3000/tcp
After killing the process, restart your development server:
# React / Create React App npm start # Vite / Modern frameworks npm run dev # Node.js / Express with nodemon npm run dev # or nodemon server.js # Next.js npm run dev # Angular ng serve
You should now see the success message:
Compiled successfully! You can now view your-app in the browser. Local: http://localhost:3000
Instead of killing processes, you can configure your app to use a different port.
# Windows set PORT=3001 && npm start # macOS/Linux PORT=3001 npm start # Or create a .env file in project root: PORT=3001
// In your server.js or app.js
const PORT = process.env.PORT || 3001; // Changed from 3000 to 3001
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
# Using environment variable
PORT=3001 npm run dev
# Or in package.json
"scripts": {
"dev": "next dev -p 3001"
}
// vite.config.js
export default {
server: {
port: 3001
}
}
// package.json
{
"scripts": {
"prekill": "taskkill /F /IM node.exe",
"start": "npm run prekill && react-scripts start",
// Or for macOS/Linux
"prekill": "lsof -ti:3000 | xargs kill -9 2>/dev/null || true",
"start": "npm run prekill && react-scripts start"
}
}
# Install nodemon npm install -g nodemon # Use nodemon instead of node nodemon server.js # Nodemon will automatically restart on file changes # and handle port cleanup better
Ctrl+C in terminal to stop servers gracefullynpx kill-port 3000npx fkill :3000Error: "Something is already running on port 3000. Would you like to run the app on another port instead?"
Solutions:
Problem: You have several projects and forget which is using which port
Solution:
# List all Node.js processes with ports lsof -i -P | grep node # macOS/Linux netstat -ano | findstr node # Windows # Kill all Node.js processes (use with caution!) pkill node # macOS/Linux taskkill /IM node.exe /F # Windows
Error: "Operation not permitted" or "Access denied"
Solutions:
# macOS/Linux: Use sudo sudo lsof -ti:3000 | xargs sudo kill -9 # Windows: Run Command Prompt/PowerShell as Administrator # Right-click → "Run as Administrator" # Then run: taskkill /PID <PID> /F
Problem: You killed the process but still get EADDRINUSE
Solutions:
lsof -i :3000 may show severalQUICK COMMANDS BY PLATFORM ========================== Windows (PowerShell - Recommended): Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess | Stop-Process -Force Windows (Command Prompt): netstat -ano | findstr :3000 taskkill /PID <PID> /F macOS: lsof -ti:3000 | xargs kill -9 Linux: lsof -ti:3000 | xargs kill -9 # or fuser -k 3000/tcp Cross-Platform (npm packages): npx kill-port 3000 npx fkill :3000
Before asking for help, verify:
Visit our Interactive Diagnostic Wizard for personalized help.