Monitor your first website free - no card needed. Explore SENRIKO

ERR_CONNECTION_REFUSED: why a site refuses to connect and what to check

A site stops opening straight after an update, yet the server still lets you in over SSH. Or a page opens on your phone while your laptop shows ERR_CONNECTION_REFUSED. These two call for different checks, so start by saving the full address of the page and finding out whether the refusal repeats on another network.

ERR_CONNECTION_REFUSED: connection refused. What to check on the server: the service, the listening port, the network rules
Contents
  1. What does ERR_CONNECTION_REFUSED mean?
  2. How do you tell whose side refused the connection?
  3. What should the site’s owner check on the server?
  4. Behind Cloudflare, a refusal looks like error 521
  5. Case: Nginx did not start after a configuration update
  6. How do you confirm the fix and catch the next refusal?
  7. Frequently asked questions about ERR_CONNECTION_REFUSED

If the refusal repeats on every connection you try, the site’s owner needs to look at the web service and its network settings. If another network opens the page, keep a note of that difference: it points to the access rules somewhere along the route. In one of our projects the cause was a single missing semicolon, and the site was back 15 minutes after the alert.

What does ERR_CONNECTION_REFUSED mean?

Chrome shows it as “This site can’t be reached” with the line that the address “refused to connect”. The browser asked to connect to an address and a port and was turned down, so no page and no HTTP status ever arrived. Chromium’s list of network errors gives it the number -102 and the words “A connection attempt was refused”.

The usual story is a domain that points at the right server while the web service on it is stopped or listens on another port. The other is a network rule that rejects the connection outright. The error tells you what happened to the attempt, not who refused it; that you have to establish yourself.

A refusal also tends to come at once, and that is a clue. A port with nothing behind it answers a connection attempt with a reset, the TCP message that ends a connection, as traceroute’s manual describes for its TCP probes. A firewall that silently drops the attempt sends nothing back, and the browser waits until it gives up with ERR_CONNECTION_TIMED_OUT instead.

Three errors that look alike, and where to start
What the browser showsWhat happenedWhat to check first
ERR_CONNECTION_REFUSEDThe attempt to connect was turned downThe service, the port, the address, the access rules
ERR_CONNECTION_TIMED_OUTThe attempt to connect never finished in timeWhether the port is reachable, and the network route
HTTP 502 Bad GatewayA gateway answered, reporting an error from the server behind itThe gateway’s and the application’s logs
Cloudflare error 521Cloudflare reached your domain, but your server refused CloudflareThe origin’s web server and its firewall

If you got a 502 rather than a browser error, read our guide to 502 Bad Gateway: that request got further and fails at another stage.

A “Sorry, we’re closed” sign hanging on a glass door
Illustration. Photo: Tim Mossholder, Unsplash.

How do you tell whose side refused the connection?

Open the same address over mobile data and compare. The scheme, the domain and the port must match: a homepage that opens over HTTP says nothing about another page over HTTPS.

  1. Copy the full address from the device that fails. Look for typos and for a port written after a colon, especially in links to admin panels and test sites.
  2. Try it on your phone with Wi-Fi off. If it opens, write down the difference between the two networks. The cause is then in the device’s settings, a proxy, a local or intermediate filter, or a server rule for certain addresses.
  3. On the original network, try another browser or a clean profile. If that works, compare the extensions and the connection settings, turning suspect extensions off one at a time.
  4. If the refusal repeats on different networks, send the site’s owner the address, the time with its time zone and a screenshot of the error. That is enough to find the attempt in the logs.

A clean profile that works is a reason to look at the main profile’s saved data and settings. Start with that one site’s data: clearing the whole history is more than this comparison needs. On a work computer with a managed proxy, agree any change with your IT team.

What should the site’s owner check on the server?

Start with the web service and its port, then the network rules. A working SSH login proves that one service answers, while the site is served by another. The same goes for ping: an ICMP reply does not test a connection over HTTPS.

On a Linux server with Nginx, if you have access, the first three commands are these:

bash
systemctl status nginx
nginx -t
ss -lntp

The first shows whether the service is running. The second tests Nginx’s configuration: nginx’s own page says it checks the syntax and then tries to open the files the configuration refers to. The third lists the TCP ports that are listening and the processes behind them; seeing the processes may take extra rights.

Read the local address in that list. 0.0.0.0:443 or [::]:443 accepts connections on every interface. 127.0.0.1:8080 accepts them only from the same machine, which is fine for an application behind a proxy on that server and useless for a visitor connecting directly.

Then match what you see with how the site is really built. If HTTPS ends at a load balancer, port 443 has to accept connections there, and the application behind it may listen on another port. An error on localhost is checked on the machine or in the container where that address was opened: for a visitor’s browser, localhost is their own device, so a published link must carry the site’s public address.

If the service runs and listens where it should, go through the local firewall, the cloud’s rules and the load balancer one at a time. Changing every layer at once leaves you unable to say which change brought the site back. Open only the port you need, and only to the clients who should reach it.

Where to start on the server: is the process running, is it listening on the right address and port, is the outside request allowed, and then a check from outside

To test from outside on Windows, use PowerShell:

powershell
Test-NetConnection example.com -Port 443

Put your own domain in place of example.com. TcpTestSucceeded speaks only of the TCP connection; whether the page itself loads is a separate request. Microsoft’s page on the command has the details. On Linux or macOS, curl -v https://example.com/ shows the same refusal in words, as it did in our case below.

Behind Cloudflare, a refusal looks like error 521

With Cloudflare in front of the site, a visitor connects to Cloudflare, and Cloudflare connects to your server. If your server turns Cloudflare away, the visitor gets Cloudflare’s own page instead of a browser error. Cloudflare’s page on error 521 says it occurs when the origin web server refuses connections from Cloudflare, and names two causes: the web server application is offline, or Cloudflare’s requests are blocked.

So the checks above still apply, on your origin rather than on Cloudflare. The one to add is the firewall or security software on the origin: Cloudflare asks you to make sure its IP ranges are allowed and not blocked or rate limited.

A “No entry” road sign against a cloudy sky
Illustration. Photo: Joe Pee, Unsplash.

Case: Nginx did not start after a configuration update

CaseAnonymous caseA main site and a new landing page on Nginx

Nginx did not start after a configuration update

What we saw
After the configuration was updated for a new landing page, the main site stopped opening for every user. SSH access kept working. A request with curl -v came back with Connection refused at once.
What we found
We checked the web server with systemctl status nginx. Nginx had failed to start after a reboot: a semicolon was missing in nginx.conf.
What we did
We fixed the typo, tested the configuration with nginx -t and restarted the service. The site was back 15 minutes after the alert.
  • every usercould not open the main site
  • 15 minutesfrom the alert to recovery

The order of the checks narrowed it down: SSH answered, so the server itself was up; curl was refused at once, so the web service was not taking connections; and the service’s status said why. Running nginx -t before every reload catches this kind of typo before it takes the site down.

How do you confirm the fix and catch the next refusal?

Repeat the original request from an outside network and open exactly the page that failed. A process shown as running does not yet prove that a visitor reaches that address.

Use the scheme and the domain from the original link, and wait for the page to finish loading. If it pulls files or an API from separate subdomains, check that those still load too. If refusals come back, save the time of each one and lay it beside the configuration changes and the service’s restarts.

An outside check shows access from its own vantage point. A refusal that happens only inside an office is reproduced on the office network and matched with its access rules.

Add the page to SENRIKO’s availability monitoring to have it checked on a schedule. It is on every plan, and the domain, DNS and certificate are checked every day. A page that cannot be reached at all is reported as such, after two failed attempts out of three, and before that alert a second location outside our data centre tries the same address; if the page opens there, no alert goes out. Finding the cause in the server’s logs stays with you. Add the same address that was refused, so its history stays comparable. What each plan includes is on the pricing page.

Frequently asked questions about ERR_CONNECTION_REFUSED

What does ERR_CONNECTION_REFUSED mean?
The browser’s attempt to connect to the address and port was turned down, so no page and no HTTP status arrived. Usually nothing is listening on that port, or a rule rejects the connection.
Is the problem on my side or the site’s?
Try the same address over mobile data. If it opens there, look at your device, browser, proxy or network. If it fails everywhere, the site’s owner has to check the server.
Why does localhost refuse to connect?
Nothing is listening on that port on the machine or in the container where you opened it, or the server listens on another port. `localhost` always means the device you are on, never a remote server.
SSH works, so why is the site refused?
SSH and the website are different services on different ports. A working SSH session proves the server is up, not that the web service is running and listening.
What is the difference between refused and timed out?
A refusal is an answer: something turned the connection down, usually at once. A timeout means no answer came at all, which often points to a firewall that drops the packets or a broken route.
Why do I see a Cloudflare 521 instead?
Cloudflare reached your domain, but your origin server refused Cloudflare’s connection. Check that the web server is running and that the origin’s firewall allows Cloudflare’s IP ranges.

Who writes this

SENRIKO team

We build the checks SENRIKO runs on websites and write about the breakages they catch.

How SENRIKO works

Hear about a breakage before your customers do

SENRIKO checks the forms, tags and cookie consent on your site and writes when something stops working. The first site is free.

Start free