ERR_CONNECTION_REFUSED on localhost:3000 - Complete Guide

Common Error Messages on localhost:3000:
• This site can't be reached - localhost refused to connect.
• ERR_CONNECTION_REFUSED
• Error: connect ECONNREFUSED 127.0.0.1:3000
• Firefox can't establish a connection to the server at localhost:3000
• Failed to load resource: net::ERR_CONNECTION_REFUSED
• Unable to connect to localhost:3000
💡 What This Error Means: ERR_CONNECTION_REFUSED on port 3000 means your browser cannot connect to the development server. This is most commonly caused by: 1) Forgetting to run npm start or yarn start, 2) The dev server crashed or failed to start (check terminal for errors), 3) The server is running on a different port (React may use 3001 if 3000 is occupied).

⚡ Quick Fix (Try This First!)

Most Common Solution:

  1. Open your terminal where you should have run npm start or yarn start
  2. Look for "Compiled successfully!" message - if you don't see it, the server isn't running
  3. If terminal is empty or shows errors: Run npm start (or yarn start or npm run dev)
  4. Wait for "Compiled successfully!" message and note the URL (might be localhost:3001 if 3000 is taken)
  5. Refresh your browser at the correct URL

🔍 Detailed Diagnosis Steps

Step 1: Check if Service is Running

🪟 Windows
netstat -ano | findstr :PORT
Example: netstat -ano | findstr :3000
🐧 Linux / 🍎 macOS
lsof -i :PORT
Example: lsof -i :3000
netstat -tlnp | grep :PORT
Alternative method

Step 2: Test Port Connectivity

telnet localhost PORT
Example: telnet localhost 3000
curl -v http://localhost:PORT
For HTTP services

Common Causes and Solutions

1. Service Not Running

Cause: The application/server is not started

Solutions:

2. Wrong Port Number

Cause: Trying to connect to the wrong port

Solutions:

3. Service Crashed or Failed to Start

Cause: The service started but then crashed

Solutions:

4. Firewall Blocking Connection

Cause: Firewall is blocking the port

Solutions:

🪟 Windows
netsh advfirewall firewall add rule name="Allow Port 3000" dir=in action=allow protocol=TCP localport=3000
🐧 Linux
sudo ufw allow 3000 (Ubuntu)
sudo firewall-cmd --add-port=3000/tcp --permanent (CentOS/RHEL)

5. Service Binding to Wrong Interface

Cause: Service is only listening on specific network interface

Solutions:

Framework-Specific Solutions for Port 3000

React (Create React App)

Verify Server is Running:

npm start or yarn start

Success message should show:

Compiled successfully! You can now view my-app in the browser. Local: http://localhost:3000 On Your Network: http://192.168.1.100:3000

Common Issues:

Next.js

npm run dev or yarn dev

Success message:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000 event - compiled client and server successfully

Change Port if Needed:

next dev -p 3001

Vite

npm run dev or yarn dev

Success message:

VITE v5.0.0 ready in 345 ms ➜ Local: http://localhost:3000/ ➜ Network: use --host to expose

Node.js/Express Custom Server

node server.js or npm start

Check server.js for:

const port = process.env.PORT || 3000; app.listen(port, () => { console.log(`Server running on http://localhost:${port}`); });

If you don't see the console.log message, the server didn't start properly.

⚠️ Prevention Tips

🔗 Related Resources

📝 Still Having Issues?

If you've tried all the solutions above and still get ERR_CONNECTION_REFUSED: