Fix "npm ERR! code EADDRINUSE" Error

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 React Node.js Express Vue Angular

What This Error Looks Like

npm Start Error:
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)
React Create App Error:
? Something is already running on port 3000.

Would you like to run the app on another port instead? (Y/n)
Node.js Server Error:
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

Quick Fix (Works 95% of the Time)

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

  1. Open Command Prompt or PowerShell
  2. Find process: netstat -ano | findstr :3000
  3. Kill process: taskkill /PID <PID> /F
  4. Run npm start again
  1. Open Terminal
  2. Find and kill: lsof -ti:3000 | xargs kill -9
  3. Run npm start again
  1. Open Terminal
  2. Find and kill: lsof -ti:3000 | xargs kill -9
  3. Run npm start again

Complete Troubleshooting Guide

1 Understand What EADDRINUSE Means

EADDRINUSE = "Error: Address Already in Use"

This error occurs when:

  • Your previous development server didn't shut down properly
  • Another application is using the same port
  • You have multiple terminals running the same project
  • A crashed process is still holding the port
Pro Tip: Common ports affected: 3000 (React), 5000 (Flask, Rails), 8080 (Spring Boot, Tomcat), 4200 (Angular), 5173 (Vite)

2 Find Which Process is Using the Port

Windows - Command Prompt

cmd
# 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)

Windows - PowerShell (Recommended)

powershell
# 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

macOS - Terminal

bash
# 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

Linux - Terminal

bash
# 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

3 Kill the Process Occupying the Port

Windows - Kill Process

cmd
# 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.

PowerShell - One-Liner Kill

powershell
# 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
}

macOS - Kill Process

bash
# 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
Note: kill -9 is a force kill (SIGKILL). Try regular kill (SIGTERM) first for graceful shutdown.

Linux - Kill Process

bash
# 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
Warning: Make sure you're killing the right process! Check the process name before killing. Killing system processes can cause issues.

4 Restart Your npm Server

After killing the process, restart your development server:

bash
# 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

5 Alternative: Change the Port Number

Instead of killing processes, you can configure your app to use a different port.

React (Create React App)

bash
# Windows
set PORT=3001 && npm start

# macOS/Linux
PORT=3001 npm start

# Or create a .env file in project root:
PORT=3001

Node.js / Express

javascript
// 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}`);
});

Next.js

bash
# Using environment variable
PORT=3001 npm run dev

# Or in package.json
"scripts": {
  "dev": "next dev -p 3001"
}

Vite

javascript
// vite.config.js
export default {
  server: {
    port: 3001
  }
}

6 Prevent Future EADDRINUSE Errors

1. Create npm Scripts to Auto-Kill Ports

json
// 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"
  }
}

2. Use Nodemon for Auto-Restart

bash
# 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

3. Always Stop Servers Properly

  • Use Ctrl+C in terminal to stop servers gracefully
  • Don't close terminal windows while servers are running
  • Check for running processes before starting new ones

4. Use Port Management Tools

Recommended Tools:
  • kill-port: npx kill-port 3000
  • fkill: npx fkill :3000
  • Cross-platform: Install globally for easy access

Common Scenarios and Solutions

Scenario 1: React App Shows Port Selection Prompt

Error: "Something is already running on port 3000. Would you like to run the app on another port instead?"

Solutions:

Scenario 2: Multiple npm Projects Running

Problem: You have several projects and forget which is using which port

Solution:

bash
# 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

Scenario 3: Permission Denied When Killing Process

Error: "Operation not permitted" or "Access denied"

Solutions:

bash
# 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

Scenario 4: Port Still Shows as Busy After Killing Process

Problem: You killed the process but still get EADDRINUSE

Solutions:

  1. Wait 30-60 seconds for the OS to release the port
  2. Check if there are multiple processes: lsof -i :3000 may show several
  3. Restart your terminal/command prompt
  4. As last resort, restart your computer

Quick Reference Cheat Sheet

cheatsheet
QUICK 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

Still Having Issues?

Before asking for help, verify:

Visit our Interactive Diagnostic Wizard for personalized help.