Fix "React Port 3000 Not Working" Issues

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.

React Create React App Vite Next.js TypeScript

Common React Port 3000 Errors

Port Already in Use Error:
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)
EADDRINUSE Error:
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
Browser Connection Refused:
This site can't be reached
localhost refused to connect.

ERR_CONNECTION_REFUSED

Try:
• Checking the connection
• Checking the proxy and the firewall
npm start Fails:
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'

Quick Fix (Choose Your Operating System)

The Problem: Another process is using port 3000

  1. Find what's using port 3000: netstat -ano | findstr :3000
  2. Note the PID (last column)
  3. Kill the process: taskkill /PID [PID] /F
  4. Or use different port: set PORT=3001 && npm start
  1. Find what's using port 3000: lsof -i :3000
  2. Kill the process: kill -9 [PID]
  3. Or use kill-port: npx kill-port 3000
  4. Or use different port: PORT=3001 npm start
  1. Find what's using port 3000: lsof -i :3000
  2. Kill the process: kill -9 [PID]
  3. Or kill all on port: lsof -ti:3000 | xargs kill -9
  4. Or use different port: PORT=3001 npm start

Complete Troubleshooting Guide

1 Identify What's Using Port 3000

cmd
# 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"
bash
# 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
bash
# Find process using port 3000
lsof -i :3000

# Alternative using netstat
netstat -tulpn | grep :3000

# Alternative using ss
ss -tulpn | grep :3000

2 Kill the Process Using Port 3000

cmd
# 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
bash
# 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
bash
# 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
Warning: Killing processes with -9 or /F forces immediate termination without cleanup. Only use this if normal termination (Ctrl+C) doesn't work.

3 Use a Different Port for React

Method 1: Environment Variable (One-time)

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

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

env
PORT=3001
BROWSER=none
FAST_REFRESH=true
CHOKIDAR_USEPOLLING=false

Method 3: Modify package.json Scripts

json
{
  "scripts": {
    "start": "PORT=3001 react-scripts start",
    "start:3000": "PORT=3000 react-scripts start",
    "start:3002": "PORT=3002 react-scripts start"
  }
}
Vite Users: For Vite projects, use npm run dev -- --port 3001 or configure in vite.config.js:
export default {
  server: {
    port: 3001
  }
}

4 Fix "Module Not Found" and Dependency Issues

If React won't start due to missing modules:

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

bash
# Clear Yarn cache
yarn cache clean

# Delete dependencies
rm -rf node_modules yarn.lock

# Reinstall
yarn install

# Start
yarn start

5 Fix ERR_CONNECTION_REFUSED in Browser

If dev server starts but browser can't connect:

Check 1: Verify Dev Server is Actually Running

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

  • Clear browser cache and cookies
  • Try incognito/private browsing mode
  • Disable browser extensions
  • Try a different browser

Check 3: Use 127.0.0.1 Instead of localhost

text
# Instead of:
http://localhost:3000

# Try:
http://127.0.0.1:3000

Check 4: Check Firewall Settings

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

6 Fix Hot Reload / Fast Refresh Issues

If React starts but changes don't reflect:

Enable Polling (for WSL, Docker, VMs):

env
# Add to .env file
CHOKIDAR_USEPOLLING=true
FAST_REFRESH=true

Increase Watcher Limit (Linux/macOS):

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

bash
# Delete cache directories
rm -rf node_modules/.cache
rm -rf .next  # for Next.js
rm -rf build  # for CRA

# Restart dev server
npm start

Common Issues and Advanced Solutions

Issue 1: Multiple React Projects Running

Problem: You have several React projects and forget which one is running

Solution:

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

Issue 2: Permission Denied Errors

On macOS/Linux:

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

Issue 3: Windows-Specific Port Issues

Reserved Ports or Hyper-V Conflicts:

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

Issue 4: TypeScript Configuration Errors

If using TypeScript and React won't start:

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

Quick Reference Commands

cheatsheet
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

Still Having Issues?

Debugging checklist:

Visit our Interactive Diagnostic Wizard for personalized help.