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 Check the exact URL, including protocol, hostname, port, and path.
- 2 Confirm the local server is running in your terminal or service manager.
- 3 Try the loopback IP version, such as http://127.0.0.1:3000/.
- 4 Check whether another process is already using the port.
- 5 Read the terminal error before changing firewall or browser settings.
Quick diagnostic checks
lsof -i :PORTIf no process is listed, the fix is to start the service or correct the port. Browser cache will not solve a missing listener.
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.
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
HTTP request 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
Localhost not working
Use a practical localhost not working checklist for wrong URLs, stopped servers, port conflicts, HTTPS mistakes, and path problems.
Port guidelocalhost:3000
Open localhost:3000, learn which development servers commonly use port 3000, and fix connection errors quickly.
Port guidelocalhost:8080
Open localhost:8080 and learn why Java servers, Tomcat apps, local proxies, and admin tools often use port 8080.
Developer toolLocalhost Port Lookup
Look up common localhost ports, what they are usually used for, and which command can check if a port is busy.
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.