Troubleshooting

Localhost refused to connect

A refused connection usually means the browser reached your machine but nothing accepted the connection on that host and port.

Fast checklist

  1. 1 Check the exact URL, including protocol, hostname, port, and path.
  2. 2 Confirm the local server is running in your terminal or service manager.
  3. 3 Try the loopback IP version, such as http://127.0.0.1:3000/.
  4. 4 Check whether another process is already using the port.
  5. 5 Read the terminal error before changing firewall or browser settings.

Quick diagnostic checks

Replace PORT with your real port lsof -i :PORT

If no process is listed, the fix is to start the service or correct the port. Browser cache will not solve a missing listener.

Ask the server directly curl -v http://localhost:PORT/

Connection refused here confirms the problem is below the browser. A 404 or 500 means the server answered and you should inspect routes or logs.

Check protocol mismatch http://localhost:PORT/

Using https against a plain http dev server can look like a localhost failure. Match the protocol printed by the server.

Live request check

What this page sees

Detecting what the server sees...
Public IP Checking...
Request line Checking...
HTTP request headers
Loading headers...

Sensitive headers such as cookies and authorization tokens are filtered before display.

What refused connection means

The browser attempted to connect, but the target host and port did not accept it. This is different from a 404, where a server answers but the path is missing.

Minimal fix path

Start the local server, copy the exact URL from the terminal, then try the loopback IP if localhost itself looks suspicious.

  • Wrong port is common.
  • HTTPS on an HTTP server fails.
  • A crashed dev server can leave an old browser tab pointing nowhere.

Do not skip the error class

A refused connection means the TCP connection was rejected. It is not the same as a 404 route miss, a 500 application crash, or an SSL warning.

  • Refused connection: start the service or change the port.
  • 404: keep the port but fix the path.
  • SSL or protocol error: switch between http and https based on the server output.

Related localhost guides

FAQ

Is refused to connect a browser problem?

Usually no. It is most often a local server, port, or protocol problem. Test with the exact URL your server printed.

Can a firewall cause localhost refused to connect?

It can, but check the local process and port first. Firewalls are less common than a stopped server or wrong port during development.

Is refused to connect the same as a 404?

No. Refused to connect means nothing accepted the connection on that host and port. A 404 means a server answered, but the requested path was missing.

Should I change firewall settings first?

Usually no. First confirm the server process is running, the port is correct, and the protocol matches. Firewall issues are more common when another device tries to reach your machine.

How do I know whether the problem is the browser or the server?

Try the same URL with 127.0.0.1, check the terminal output, and use a command such as lsof -i :PORT. If no process is listening, the server side needs attention.