Troubleshooting guide
ERR_CONNECTION_REFUSED: how to fix it
Connection refused means the browser reached the machine, and the machine actively said no. The network works; nothing is accepting connections on that port.
3 min read10 sectionsUpdated
On this page
Common causes
- The web server is stopped or crashed.
- Wrong port, such as a dev server on 3001 while you open 3000.
- Bound to localhost only. A service listening on
127.0.0.1is unreachable from outside, and in Docker, from outside the container. - A firewall set to reject.
- A VPN or local proxy intercepting connections.
- DNS pointing at an old server that no longer runs the site.
Diagnose it
On the server, check whether anything is listening and on which address. 0.0.0.0 means every interface, and 127.0.0.1 means local only.
# Is anything listening on 443 or 3000?
sudo ss -ltnp | grep -E ':(443|3000)\b'
# Test from outside: refused, or timeout?
nc -vz example.com 443
# Is the service up, and why did it stop?
systemctl status nginx --no-pager
journalctl -u nginx -n 50 --no-pager
# Docker: is the port actually published?
docker ps --format '{{.Names}} {{.Ports}}'Fixes
As a visitor: check the address and port, disable any VPN or proxy, and try another network or a phone. If the site fails everywhere, the site is down.
As a site owner: start the service and read why it stopped. Bind to 0.0.0.0 if it must accept outside connections, particularly inside a container. Publish the port in Docker. Check firewall rules with ufw status and cloud security groups, and confirm DNS points to the current server.
For local development: make sure the dev server is running, and open the port it printed.
Catch it automatically
A TCP or HTTP uptime check from several regions tells you within a minute when connections begin to be refused, and tells you the difference between refused and timed out. Add a process supervisor so a crashed service restarts by itself, then alert on the restarts, since a service that keeps restarting is still broken.
What is the difference between connection refused and timed out?
Refused is an immediate rejection: the host answered and nothing was listening. Timed out means no answer at all, often a firewall dropping packets or a host that is down.
Why does localhost refuse to connect?
Your local server is not running, or runs on a different port. Check the terminal where you started it.
Why can I reach it on the server but not from outside?
The service is probably bound to 127.0.0.1, or a firewall blocks the port.
Check it now, free
- Open port checker: Is a TCP port open, closed or filtered from the internet?
Related reading
- "This site can’t be reached": how to fix it: Fix Chrome’s "This site can’t be reached": DNS failures, refused or timed-out connections and blocked networks, for visitors and for site owners.
- ERR_SSL_PROTOCOL_ERROR: how to fix it: Fix ERR_SSL_PROTOCOL_ERROR ("This site can't provide a secure connection"): HTTP on port 443, old TLS versions, broken TLS setups, proxies and antivirus.
- Redis connection refused: how to fix it: Fix Redis connection refused on port 6379: server stopped, bind address, protected mode and Docker networking, with redis-cli and ss commands for each cause.
- ERR_CONNECTION_CLOSED: how to fix it: Fix ERR_CONNECTION_CLOSED: servers closing connections early, TLS problems, firewalls, crashing apps and proxy timeouts, with checks for site owners.
- ERR_CONNECTION_RESET: causes and how to fix it: Fix ERR_CONNECTION_RESET: crashed backends, firewalls and antivirus resetting traffic, MTU problems and keep-alive races, for both visitors and site owners.
- ERR_TUNNEL_CONNECTION_FAILED: how to fix it: Fix ERR_TUNNEL_CONNECTION_FAILED: proxy servers refusing HTTPS tunnels, wrong proxy settings, VPN apps and corporate filters, step by step.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.