Can't start your React development server on port 3000? Getting "port already in use", "ERR_CONNECTION_REFUSED", or other port 3000 errors? This complete guide covers all React port 3000 troubleshooting for Create React App, Vite, and Next.js.
Something is already running on port 3000. Would you like to run the app on another port instead? › (Y/n) ? Something is already running on port 3000. Probably: node (pid 12345) in /Users/username/projects/my-app Would you like to run the app on another port instead? (Y/n)
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1318:16)
at listenInCluster (net.js:1366:12)
events.js:292
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use 127.0.0.1:3000
This site can't be reached localhost refused to connect. ERR_CONNECTION_REFUSED Try: • Checking the connection • Checking the proxy and the firewall
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: `react-scripts start` npm ERR! Exit status 1 Failed to compile. ./src/App.js Module not found: Can't resolve 'react'
The Problem: Another process is using port 3000
netstat -ano | findstr :3000taskkill /PID [PID] /Fset PORT=3001 && npm startlsof -i :3000kill -9 [PID]npx kill-port 3000PORT=3001 npm startlsof -i :3000kill -9 [PID]lsof -ti:3000 | xargs kill -9PORT=3001 npm start# Find process using port 3000 netstat -ano | findstr :3000 # Output example: # TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 12345 # The last number (12345) is the PID # Find process name by PID tasklist | findstr "12345"
# Find process using port 3000 lsof -i :3000 # Output example: # COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME # node 12345 user 20u IPv6 0x... 0t0 TCP *:3000 (LISTEN) # More detailed info lsof -i :3000 -P
# Find process using port 3000 lsof -i :3000 # Alternative using netstat netstat -tulpn | grep :3000 # Alternative using ss ss -tulpn | grep :3000
# Method 1: Kill by PID taskkill /PID 12345 /F # Method 2: Kill all Node processes (use with caution) taskkill /IM node.exe /F # Method 3: PowerShell one-liner Get-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess | Stop-Process -Force
# Method 1: Kill by PID kill -9 12345 # Method 2: Kill all processes on port 3000 lsof -ti:3000 | xargs kill -9 # Method 3: Using npx kill-port (recommended) npx kill-port 3000 # Method 4: Kill specific port range npx kill-port 3000 3001 3002
# Method 1: Kill by PID kill -9 12345 # Method 2: Kill all processes on port 3000 lsof -ti:3000 | xargs kill -9 # Method 3: Using fuser fuser -k 3000/tcp # Method 4: Using npx kill-port npx kill-port 3000
-9 or /F forces immediate termination without cleanup. Only use this if normal termination (Ctrl+C) doesn't work.
Method 1: Environment Variable (One-time)
# macOS/Linux PORT=3001 npm start # Windows CMD set PORT=3001 && npm start # Windows PowerShell $env:PORT=3001; npm start
Method 2: Create .env File (Persistent)
# Create .env file in project root echo "PORT=3001" > .env # Or for Windows: echo PORT=3001 > .env # Then run normally npm start
Example .env file:
PORT=3001 BROWSER=none FAST_REFRESH=true CHOKIDAR_USEPOLLING=false
Method 3: Modify package.json Scripts
{
"scripts": {
"start": "PORT=3001 react-scripts start",
"start:3000": "PORT=3000 react-scripts start",
"start:3002": "PORT=3002 react-scripts start"
}
}
npm run dev -- --port 3001 or configure in vite.config.js:
export default {
server: {
port: 3001
}
}
If React won't start due to missing modules:
# Step 1: Clear npm cache npm cache clean --force # Step 2: Delete node_modules and package-lock.json rm -rf node_modules package-lock.json # Windows: rmdir /s node_modules & del package-lock.json # Step 3: Reinstall dependencies npm install # Step 4: Try starting again npm start
If using Yarn:
# Clear Yarn cache yarn cache clean # Delete dependencies rm -rf node_modules yarn.lock # Reinstall yarn install # Start yarn start
If dev server starts but browser can't connect:
Check 1: Verify Dev Server is Actually Running
# Check if port 3000 is listening lsof -i :3000 # Mac/Linux netstat -an | findstr :3000 # Windows # Look for terminal output like: # "webpack compiled successfully" # "Compiled successfully!"
Check 2: Try Different Browser/Incognito Mode
Check 3: Use 127.0.0.1 Instead of localhost
# Instead of: http://localhost:3000 # Try: http://127.0.0.1:3000
Check 4: Check Firewall Settings
# Windows: Allow Node.js through firewall # Control Panel → Windows Defender Firewall → Allow an app # macOS: Check firewall settings # System Preferences → Security & Privacy → Firewall # Linux: Allow port 3000 sudo ufw allow 3000/tcp
If React starts but changes don't reflect:
Enable Polling (for WSL, Docker, VMs):
# Add to .env file CHOKIDAR_USEPOLLING=true FAST_REFRESH=true
Increase Watcher Limit (Linux/macOS):
# Temporary fix echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf sudo sysctl -p # Check current limit cat /proc/sys/fs/inotify/max_user_watches
Clear Webpack Cache:
# Delete cache directories rm -rf node_modules/.cache rm -rf .next # for Next.js rm -rf build # for CRA # Restart dev server npm start
Problem: You have several React projects and forget which one is running
Solution:
# Find all Node processes # macOS/Linux: ps aux | grep node # Windows: tasklist | findstr node # Kill all Node processes (use with caution!) # macOS/Linux: pkill -9 node # Windows: taskkill /IM node.exe /F
On macOS/Linux:
# Don't use sudo with npm! # Instead, fix npm permissions: # Create npm global directory mkdir ~/.npm-global # Configure npm npm config set prefix '~/.npm-global' # Add to PATH (add to ~/.profile or ~/.zshrc) export PATH=~/.npm-global/bin:$PATH # Reload shell source ~/.profile
Reserved Ports or Hyper-V Conflicts:
# Check reserved port ranges netsh interface ipv4 show excludedportrange protocol=tcp # If port 3000 is in excluded range, use different port # Or disable Hyper-V (requires restart): bcdedit /set hypervisorlaunchtype off # Re-enable Hyper-V: bcdedit /set hypervisorlaunchtype auto
If using TypeScript and React won't start:
# Ensure TypeScript is installed npm install --save-dev typescript @types/react @types/react-dom @types/node # Delete and regenerate tsconfig.json rm tsconfig.json npm start # Will regenerate automatically # Or create fresh tsconfig.json npx tsc --init
REACT PORT TROUBLESHOOTING CHEATSHEET
======================================
Find what's using port 3000:
macOS/Linux: lsof -i :3000
Windows: netstat -ano | findstr :3000
Kill process on port 3000:
macOS/Linux: kill -9 [PID]
Windows: taskkill /PID [PID] /F
Universal: npx kill-port 3000
Kill all processes on port:
macOS/Linux: lsof -ti:3000 | xargs kill -9
Windows: FOR /F "tokens=5" %P IN ('netstat -ano ^| findstr :3000') DO TaskKill /PID %P /F
Use different port:
One-time: PORT=3001 npm start (Mac/Linux)
set PORT=3001 && npm start (Windows)
Persistent: Create .env with PORT=3001
Clean install:
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
npm start
Quick fixes:
Clear cache: rm -rf node_modules/.cache
Enable polling: CHOKIDAR_USEPOLLING=true npm start
Use 127.0.0.1: http://127.0.0.1:3000 instead of localhost
Debugging checklist:
node -v && npm -v)npm install)Visit our Interactive Diagnostic Wizard for personalized help.