How to Fix Chrome ERR_CONNECTION_REFUSED on Localhost

If you’re a web developer, you’ve probably seen this error at some point: ERR_CONNECTION_REFUSED appearing in your Chrome browser when trying to access localhost. It can be frustrating, especially when you’re sure your development server should be running. The good news is this error is usually straightforward to fix, and in this guide, I’ll walk you through every practical solution.

What Does ERR_CONNECTION_REFUSED Mean?

When Chrome shows ERR_CONNECTION_REFUSED, it simply means the browser tried to connect to a server at the address you specified, but the server actively rejected the connection. In the context of localhost, this typically happens because:

  1. No development server is running on the port you specified
  2. The server is listening on a different port than you expected
  3. A firewall is blocking the connection
  4. The server is bound to a different network interface

Let’s fix this step by step.

Step 1: Verify Your Development Server Is Running

Before anything else, make sure your development server is actually running. It sounds obvious, but it’s the most common cause of this error.

  • Check your terminal — Look for the terminal window where you started your server (whether it’s Node.js, Python, PHP, or something else). Make sure it didn’t crash or stop running.
  • Look for the correct port — Most frameworks default to specific ports (3000 for React, 5000 for Flask, 8080 for Apache, etc.). Verify which port your server is actually listening on.
  • Restart the server — If you’re unsure, stop the server and restart it. This often resolves transient issues.

If your server is running but you’re still getting the error, move to the next step.

Step 2: Use the Correct Port Number

One of the most frequent causes of ERR_CONNECTION_REFUSED is a simple port mismatch. You’re trying to access port 3000, but your server is actually running on port 5173 (common with Vite) or another port entirely.

How to check which port your server is using:

  • Look in your terminal output when the server starts — it usually says something like “Server running at http://localhost:5173”
  • Check your package.json or server configuration file for the port setting
  • If you’re using a framework like Express, check your app.js or server.js for the port variable

Once you know the correct port, update your URL accordingly. For example, change http://localhost:3000 to http://localhost:5173.

Step 3: Try 127.0.0.1 Instead of localhost

Sometimes Chrome has issues resolving “localhost” due to DNS configuration or IPv6 issues. Try using the IP address directly:

Instead of: http://localhost:3000 Try: http://127.0.0.1:3000

If this works, you know the issue is with hostname resolution rather than the server itself. To fix this permanently, you can edit your hosts file, but using 127.0.0.1 is a quick workaround.

Step 4: Check for Port Conflicts

Another server might be using the port you need. This happens frequently when you forget to stop a previous server session.

On Windows: Open Command Prompt and run:

netstat -ano | findstr :3000

Replace 3000 with your port number. The output will show you the Process ID (PID) using that port. You can then end that process using Task Manager or by running taskkill /PID [PID].

On Mac: Open Terminal and run:

lsof -i :3000

This shows what’s using the port. You can then kill it using kill -9 [PID].

On Linux: Similar to Mac, use:

sudo lsof -i :3000

Then kill the process with kill -9 [PID].

After freeing up the port, restart your development server.

Step 5: Check Firewall Settings

Firewalls can block localhost connections, especially on Windows. If you’ve recently updated your firewall rules or installed new security software, it might be preventing Chrome from connecting to your local server.

On Windows:

  1. Go to Windows Security → Firewall & network protection
  2. Check if your firewall is blocking your development environment or Node.js/Python
  3. Add an exception for your development server if needed

On Mac:

  1. Go to System Preferences → Security & Privacy → Firewall
  2. Make sure your development tools aren’t blocked

If you’re running a development server for the first time, your operating system might have prompted you to allow network connections — check if you accidentally denied it.

Step 6: Clear Chrome’s Cache and Cookies

While less common, cached data can sometimes cause connection issues. Clear your browser cache for localhost specifically:

  1. Press F12 to open Developer Tools
  2. Right-click the refresh button and select “Empty Cache and Hard Reload”
  3. Alternatively, go to Settings → Privacy and security → Clear browsing data

This forces Chrome to make a fresh connection to your local server.

Step 7: Check Your Server Binding

Your server might be configured to listen only on a specific network interface. By default, most development servers listen on all interfaces (0.0.0.0) or localhost (127.0.0.1), but some configurations restrict this.

If you’re using:

  • Node.js/Express: Check if you’re using app.listen(port, '127.0.0.1') — change it to app.listen(port) or app.listen(port, '0.0.0.0')
  • Python Flask: Use app.run(host='0.0.0.0', port=5000)
  • PHP built-in server: Use php -S localhost:8000 or php -S 0.0.0.0:8000

Step 8: Check for HTTPS Mixed Content Issues

If you’re accessing your local server over HTTPS but it only supports HTTP, Chrome might block the connection. Make sure you’re using http:// not https:// for localhost development, or configure your server to support HTTPS if you need it.

Quick Checklist

When facing ERR_CONNECTION_REFUSED, run through this checklist:

  • Is your development server actually running?
  • Are you using the correct port number?
  • Have you tried 127.0.0.1 instead of localhost?
  • Is another process using the same port?
  • Is your firewall blocking the connection?
  • Did you clear Chrome’s cache?

A Note on Managing Tabs During Development

If you work with multiple local projects simultaneously, you might find yourself with dozens of browser tabs open — each pointing to a different localhost port. This can slow down your browser significantly, especially on computers with limited RAM.

This is where Tab Suspender Pro comes in handy. It automatically suspends inactive tabs, including your localhost development pages, which frees up memory and keeps your browser responsive. When you click a suspended tab, it instantly reloads — perfect for developers juggling multiple projects. This extension helps you maintain a cleaner browser workspace without losing track of your development environments.

Final Thoughts

ERR_CONNECTION_REFUSED on localhost is usually a simple fix. In most cases, it’s either the server isn’t running, you’re using the wrong port, or there’s a minor configuration issue. By working through these steps systematically, you’ll identify and resolve the problem quickly.

Remember: always double-check that your development server is running and note the correct port from the terminal output. Most of the time, that’s all it takes to get past this error.

Built by theluckystrike — More tips at zovo.one