Find out why your server is refusing connections
ERR_
Why a server refuses connections
The web server isn't running
If the web server stopped, crashed or failed to start after a reboot or a deploy, nothing holds the port open. The operating system then answers each new connection on that port with a refusal.
It listens on a different port
A server set up on port 8080 or 3000 refuses visitors who arrive on 80 or 443. The same thing happens when HTTP works on port 80 but nothing was ever set up to answer HTTPS on 443.
It listens only on the loopback address
A server bound to 127.0.0.1 or localhost accepts connections from its own machine and refuses everything arriving on the public address. That's the right setup for an app behind a local proxy and the wrong one for a server visitors reach directly.
A firewall rejects the traffic
A firewall rule that rejects with a TCP reset or an ICMP port unreachable message, rather than silently dropping the traffic, sends a refusal back to the browser. A rule that drops the traffic shows up as a timeout instead, and one that rejects with a prohibited message can show up as ERR_
ADDRESS_ UNREACHABLE in Chrome. DNS points at the wrong machine
If the record still holds the address of an old server, the machine at that address can refuse because it no longer runs your site. Compare the address the name resolves to with your server's.
net_
Test the port from outside, then on the server
# From your own computer: does anything accept connections on 443?
nc -vz yoursite.com 443
# The same test with curl; exit code 7 means it couldn't connect
curl -sS -o /dev/null https://yoursite.com/; echo "exit $?"
# On the server (Linux): which programs listen on 80 and 443, and on which address?
sudo ss -ltnp | grep -E ':(80|443)\s'
Read what the port tests show
If
sslists nothing on port 443, no web server is listening there. Start it, then read its error log for why it stopped or never started. If it lists the port only on127.0.0.1or[::1], the server accepts connections from itself alone; change its listen address to0.0.0.0,[::]or the server's public address. The ss manual explains each option used above.If the server listens on the public address and
ncfrom your computer still says the connection was refused, something between you and the program is rejecting it: the server's own firewall, a network firewall at your host, or a different machine answering because your DNS record points elsewhere, whichdig +shorton your domain will show. curl's error list defines exit code 7 as a failure to connect to the host.
How to fix a refused connection
- Start the web server and keep it runningStart the service, then find out from its log why it stopped. Set it to start at boot and to restart after a crash, so one failure or a reboot doesn't leave the port closed.
- Listen on the right port and addressMake the server listen on 443 for HTTPS and 80 for HTTP, on its public address or on all addresses. If your app listens on another port, put a web server or proxy in front of it on 443.
- Open the port in every firewallAllow inbound connections on 80 and 443 in the server's own firewall and in any network firewall or security group your host provides. If a CDN connects on visitors' behalf, allow its addresses too.
- Point the domain at this serverMake the A record, and the AAAA record if you publish one, hold this server's current address. Then repeat the nc test from outside to confirm the connection opens.
Frequently asked questions
Why does the site work on the server but refuse visitors?
The server is probably listening on 127.0.0.1 only, or a firewall rejects outside traffic. A test like curl http://localhost on the server goes to the loopback address, which a 127.0.0.1-only server accepts and which network firewalls never see, so it succeeds while visitors are refused. Compare the addresses ss -ltn lists with the address visitors use.
Is a refused connection the same as a timeout?
No. A refusal comes back right away, because a host at that address answered and turned the connection down. A timeout means nothing answered at all, which points to a server that's offline or a firewall that drops traffic silently. The guide to timed-out connections, linked below, covers that case.
What do visitors see when a CDN sits in front of the server?
Not this error, since their browser connected to the CDN without trouble. The CDN shows its own error page instead, such as Cloudflare's error 521 for an origin that refused the connection, and the fix on your server is the same.
How do I find out when the web server stops?
A web server that doesn't come back after a reboot keeps refusing every visitor until someone notices and starts it by hand. SiteCMD requests your home page every few minutes once you add the site, and it emails you when the site goes down and again once it recovers.
Other reasons your site won't connect
- Website reliabilityHear about it when your site goes down, not days later from a customer.
- Cloudflare error 521Get the web server running on the port Cloudflare uses, then make sure nothing on the origin blocks Cloudflare's addresses.
- Connection timed outFind what's swallowing connection requests to your server, from a silent firewall to an address nobody answers on.
- Is my website down?Tell your own connection apart from a real outage, then trace the error to its cause.