Skip to content

Connection Refused

DownBad reached your server, but the server turned the connection away, because nothing on it is taking connections where DownBad knocked. Usually a program has stopped. This page helps you find out which one, start it again, and see the incident close.

An incident is open for a URL, port or SSL monitor, and it shows one of these reasons:

  • Connection refused: connect ECONNREFUSED 203.0.113.10:443, on a URL monitor, with the failure type network.
  • Connection refused: Unknown error occurred, on a URL monitor, with the failure type network. This one names nothing specific, but it means the same as the one above. You see it when your address has both an IPv4 and an IPv6 address (the older and the newer kind of internet address), DownBad tried both, and both refused.
  • Port connection refused: Port 8080 is not listening on example.com, on a port monitor, with the failure type connection refused.
  • SSL connection refused: Operation failed after 4 attempts. Last error: connect ECONNREFUSED 203.0.113.10:443, on an SSL monitor, with the failure type network. An SSL monitor tries more than once before it gives up, and the reason says how many times.
  • SSL connection refused: Operation failed after 4 attempts. Last error: AggregateError, on an SSL monitor, with the failure type network. It means the same as the one above, for an address with both an IPv4 and an IPv6 address.

A server offers each of its services behind a numbered port: 443 for secure web pages (https://), 80 for plain ones (http://), and other numbers for anything else. A program that offers a service is listening on its port, waiting for connections.

Refused means DownBad reached your server, and the server answered straight away that nothing is listening on that port. ECONNREFUSED is the error code for exactly that, and the address after it is the server and port DownBad tried. A refusal is different from a timeout: refused means something answered “no one’s here”, while timed out means nothing answered at all.

It is almost always your server. A refusal is an answer that comes back from the address your monitor points at.

DownBad didn’t open this incident on one check, either. When a check is refused, DownBad first checks again from up to three other places in the United States, and opens the incident only when at least half of the places that answered failed too.

The trap is testing from the wrong place. A program that listens only for the server itself answers when you try from the server, and refuses everyone else. So check from outside:

  1. For a URL monitor, turn off Wi-Fi on your phone and open the address over mobile data. Chrome and Edge show ERR_CONNECTION_REFUSED when the connection is refused.

  2. For any monitor, run a free check from other countries at check-host.net. Enter your host name and port, such as example.com:443. Each location’s result says Connection refused when the port refuses.

  3. Read the results:

    • Refused from outside: your server really is turning connections away. Carry on below.
    • It works from everywhere: the problem has gone. Skip to Confirm DownBad sees the fix.

These commands try to connect the way DownBad does. Run the first three from a computer outside your server’s own network, such as your laptop, not from the server. Put your own host name in place of example.com.

1. Find the port DownBad connects to. It depends on the kind of monitor:

  • Port monitor: its Port Number setting.
  • SSL monitor: its Port setting, which is 443 unless you changed it.
  • URL monitor: the number after the colon in its URL, if there is one, so https://example.com:8443/ uses 8443. Otherwise 443 for an address that starts with https://, and 80 for http://.

The commands below use 443. Put your monitor’s port in its place.

2. Try to connect to the port:

Terminal window
nc -vz -G 5 example.com 443
If it works
Connection to example.com port 443 [tcp/https] succeeded!

No public address refused from the network these examples came from, so this refusal is from a closed port on the Mac itself, 127.0.0.1 port 8443:

If it's refused
nc: connectx to 127.0.0.1 port 8443 (tcp) failed: Connection refused

If it says timed out instead of Connection refused, nothing answered at all. That is a different problem from the one on this page: something is dropping the connection, or the server itself is down. On Windows, check-host.net (above) shows which of the two happened.

3. If it’s a URL monitor, ask for the page. This follows redirects (a page sending the visitor on to another address), as DownBad’s check does unless the monitor says otherwise:

Terminal window
curl -sS -L -o /dev/null -w "%{http_code}\n" https://example.com/
If it works
200

As in step 2, this refusal is from a closed port on the Mac itself:

If it's refused
curl: (7) Failed to connect to 127.0.0.1 port 8089 after 0 ms: Couldn't connect to server
000

(7) is curl’s code for a connection it couldn’t open, and 000 means no answer came back at all.

4. On the server, list what is listening. Log in to the server and run the command for the server’s system, which may not be the same as your own computer’s. It only reads:

Terminal window
netstat -an -p tcp | grep LISTEN
If it works
tcp46 0 0 *.443 *.* LISTEN
If only the server itself can connect
tcp4 0 0 127.0.0.1.6443 *.* LISTEN

The macOS and Linux examples show one program listening on port 443 for everyone and another listening on port 6443 for the server alone. Microsoft’s Windows example shows one listening on port 3389 for everyone. How to read your own list:

  • Find your port at the end of an address, after the last : or ..
  • Your port isn’t in the list: nothing is listening on it. Go to the first cause.
  • Your port is there after 0.0.0.0, *, :: or [::]: a program is listening for everyone, so something else is doing the refusing. Go to the monitor’s settings, and then to the firewall: the firewall is the software that decides which connections get through.
  • Your port is there only after 127.0.0.1, ::1 or [::1]: that is localhost, an address only the server itself can reach. Go to the localhost cause.

Without a terminal: check-host.net runs step 2 from many countries, and its HTTP check runs step 3. Both say Connection refused when the connection is refused, and Connection timed out when nothing answered.

The causes below run from most to least likely, so start with the first. If this monitor has never passed since you added it, the monitor’s settings and localhost are more likely than a program that stopped.

Most steps happen on the server itself, so you need to log in to it: with SSH (a way to open a terminal on another computer), or through the console in your hosting provider’s dashboard. A step that changes the server needs sudo on Linux, which runs a command as the server’s administrator and asks for your password, or on Windows a PowerShell window opened with Run as Administrator. Each such step says so.

If someone else runs the server for you, such as a managed hosting company or a website builder, send them the reason the incident shows and a link to this page. The fix is theirs to make.

This is the usual cause when the monitor used to pass. The program that answers on the port has stopped: a web server such as nginx, Apache or IIS (Microsoft’s web server), or your own app. You can tell because the server’s list of listening ports, from step 4 of Check it yourself, doesn’t include the monitor’s port.

  1. Check the program’s state. On Linux, most programs run as a service, a program the system starts and watches for you. Put your program’s service name in place of nginx: apache2 or httpd for Apache, or your app’s own name. On Windows, IIS runs as the service named W3SVC.

A Mac serving a website usually runs the program by hand, not as a service. If its port isn’t in the list from step 4 of Check it yourself, it has stopped.

An app run by pm2 (a program that keeps Node.js apps running) or in a Docker container (a sealed-off package holding a program and everything it needs) is checked the same way on every system. Put your app’s or container’s name in place of web.

Terminal window
pm2 list
If it works
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
│ 0 │ web │ default │ N/A │ fork │ 7484 │ 1s │ 0 │ online │ 0% │ 55.3mb │ deploy │ disabled │
If it was stopped
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
│ 0 │ web │ default │ N/A │ fork │ 0 │ 0 │ 1 │ stopped │ 0% │ 0b │ deploy │ disabled │
Terminal window
docker ps -a
If it works
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
af80e2296064 nginx:stable "/docker-entrypoint.…" 2 seconds ago Up 2 seconds 80/tcp web
If it was stopped
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
af80e2296064 nginx:stable "/docker-entrypoint.…" 2 seconds ago Exited (0) Less than a second ago web
  1. If it crashed, find out why before you start it again, or it will stop again. On Linux, the last lines the program wrote are at the bottom of the systemctl status output, as in the crashed example above: nginx names the mistake, unknown directive "lisen", and the file and line it is on. If the bottom of the output says that some journal files were not opened due to insufficient permissions, run the same command with sudo. A mistake in a settings file you just changed and a full disk are common culprits.

  2. Start it again. This changes the server, so it needs sudo on Linux, and a PowerShell window opened with Run as Administrator on Windows.

Start the program again the same way you started it before. A program started by hand in a terminal usually stops when that terminal closes, so to keep it running, run it under pm2 or in a Docker container.

For pm2 or Docker, on any system:

Terminal window
pm2 restart web
If it works
[PM2] Applying action restartProcessId on app [web](ids: [ 0 ])
[PM2] [web](0) ✓
If there's no app by that name
Use --update-env to update environment variables
[PM2][ERROR] Process or Namespace web not found
Terminal window
docker start web
If it works
web
If there's no container by that name
Error response from daemon: No such container: web
failed to start containers: web

More in the guides for systemctl, nginx, Apache and pm2.

  1. Run step 4 of Check it yourself again. The monitor’s port should now be in the list.

The server restarted, and the program didn’t start with it

Section titled “The server restarted, and the program didn’t start with it”

This is the likely cause when the program was running before, the server restarted, such as for an update or your provider’s maintenance, and the program is stopped now. A program only comes back after a restart if it is set to start when the server does.

  1. Check whether it is set to start with the server. Put your program’s service name in place of nginx, or your container’s name in place of web.

A program you start by hand on a Mac never starts with it. Run it under pm2 or in a Docker container instead, and set that up as below.

For a Docker container, on any system:

Terminal window
docker inspect --format '{{.HostConfig.RestartPolicy.Name}}' web
If it works
unless-stopped
If it doesn't come back by itself
no

An app run by pm2 only comes back after a restart once pm2 itself is set to start with the server, as pm2’s startup guide explains.

  1. Set it to start with the server, and start it now. This changes the server, so it needs sudo on Linux, and a PowerShell window opened with Run as Administrator on Windows.

Run the program under pm2 or in a Docker container, as below, so it comes back by itself.

For a Docker container, on any system, set it to come back by itself (Docker’s guide), then start it:

Terminal window
docker update --restart unless-stopped web
If it works
web
If there's no container by that name
Error response from daemon: No such container: web
Terminal window
docker start web
If it works
web
If there's no container by that name
Error response from daemon: No such container: web
failed to start containers: web

For pm2, follow pm2’s startup guide. More on systemd is in the systemctl guide.

  1. Run step 4 of Check it yourself again. The monitor’s port should now be in the list.

It listens only on localhost, or on another port

Section titled “It listens only on localhost, or on another port”

This is the likely cause when the program is running, but the server’s list from step 4 of Check it yourself shows it at a different port from the monitor’s, or only after 127.0.0.1, ::1 or [::1]. That address is localhost: only the server itself can reach it, so the program answers there and refuses everyone else.

  1. Decide whether the program is meant to be reached from outside. An app behind nginx or Apache is often meant to listen on localhost only, while the web server takes the public connections and passes them on. If that is your set-up, leave the app alone and check that the monitor points at the web server’s port.

  2. Otherwise, find the setting that chooses the program’s address and port, and make it listen on every address, at the port the monitor uses:

    • nginx: a listen line such as listen 443 ssl; listens on every address. One with 127.0.0.1: before the port listens on localhost only (nginx’s guide).
    • Apache: Listen 80 listens on every address, and Listen 127.0.0.1:80 on localhost only (Apache’s guide).
    • IIS: check the site’s Bindings in IIS Manager (Microsoft’s guide).
    • A Node.js app: the host it passes to listen. Leave the host out, or use 0.0.0.0, to listen on every address (Node.js’s guide).
    • A Docker container: its ports are set when it is created. The PORTS column of docker ps shows 0.0.0.0:8080->80/tcp for a port published to everyone, 127.0.0.1:8080->80/tcp for one published only to the server, and just 80/tcp for one not published at all. Create the container again with -p 8080:80, your own ports in place of these (Docker’s guide).
  3. Restart the program so it reads the change. This changes the server, so it needs sudo on Linux, and a PowerShell window opened with Run as Administrator on Windows.

Stop the program and start it again the same way you started it before.

For an app run by pm2, on any system:

Terminal window
pm2 restart web
If it works
[PM2] Applying action restartProcessId on app [web](ids: [ 0 ])
[PM2] [web](0) ✓
If there's no app by that name
Use --update-env to update environment variables
[PM2][ERROR] Process or Namespace web not found
  1. Run step 4 of Check it yourself again. The monitor’s port should now be listed after 0.0.0.0, *, :: or [::].

This is the likely cause when the program is running and listening for everyone, but on a different port from the one the monitor checks, or when the address in the incident’s reason isn’t your server’s.

  1. Open the monitor’s settings and read what it connects to:

    • Port monitor: Hostname and Port Number.
    • SSL monitor: Domain and Port.
    • URL monitor: URL. A port after a colon counts, and otherwise https:// means port 443 and http:// means port 80.
  2. Compare the port with the server’s list from step 4 of Check it yourself. Two mix-ups are common: an https:// address for a site that only serves plain http:// on port 80, and a monitor on an app’s own port, such as 3000, when the public port is 80 or 443.

  3. Compare the address. In a reason such as connect ECONNREFUSED 203.0.113.10:443, the number before the colon is the server DownBad reached. If it isn’t your server’s address, your domain’s DNS records (the settings that turn its name into an address) still point somewhere else, such as a server you moved away from. Update them where you manage your domain.

  4. Correct the setting and save the monitor.

This is the likely cause when the server’s list shows the program listening for everyone, on the right port, and connecting from outside is still refused. A firewall usually ignores a connection it doesn’t want, which reads as a timeout. One set to reject answers straight away instead, and that looks exactly like nothing listening.

  1. Check the firewall on the server. On Ubuntu, the firewall is usually ufw, and reading its rules needs sudo.

Look in the settings of any firewall the Mac runs for a rule that turns away connections to the monitor’s port.

  1. On Ubuntu, allow the port. This changes the server, and needs sudo. Put the monitor’s port in place of 443:

    Terminal window
    sudo ufw allow 443/tcp
    If it works
    Rule updated
    Rule updated (v6)
    If you left out sudo
    ERROR: You need to be root to run this script

    More in Ubuntu’s ufw guide.

  2. If the server sits behind another firewall or a router you manage, check that it passes the monitor’s port through to the server as well.

  1. Fix the cause first. A check that still fails while you work only adds to the time the incident takes to close.

  2. Open the incident and press Test Now. DownBad checks again within a few seconds instead of waiting for the next scheduled check.

  3. Wait a minute, then reload the incident page, which doesn’t update by itself. The incident closes by itself once enough checks in a row pass. You can’t close an incident by hand.

How many passing checks it takes. While an incident is open, DownBad checks less often after repeated failures. This is called back-off. Each failed check adds one step of back-off, up to 14. Each passing check takes one step away and asks for the next check straight away. When no steps are left, one more passing check closes the incident. So after a steady outage it takes one more passing check than there were failed checks while the incident was open, counting the one that opened it, and never more than 15.

These are the defaults. The monitor’s notification profile can change them for each monitor type under Backoff Config, and its settings are the ones that count: Recovery is how many passing checks in a row, with no back-off left, close the incident (2 by default, counting the check that takes the last step away), and Start after, Rate and Max interval decide when back-off starts and how far it goes. If the profile changes them, the step counts above and the waits below change with them.

How long that takes. After you press Test Now, those passing checks run back to back, a few seconds apart, so the incident usually closes within a minute. It takes longer when checks are slow to finish, such as a page that takes several seconds to load.

If you don’t press Test Now, the first passing check waits for the next scheduled one. With the default settings, from the third failed check on, DownBad waits 5 more minutes for each failure, up to an hour more than the monitor’s usual interval:

Monitor checks everyAfter 1 or 2 failed checksAfter 3After 6After 14 or more
1 minute1 minute6 minutes21 minutes61 minutes
5 minutes5 minutes10 minutes25 minutes65 minutes
1 hour1 hour1 hour 5 minutes1 hour 20 minutes2 hours
1 day1 day1 day 5 minutes1 day 20 minutes1 day 1 hour

Before you ask for help, collect:

  • the link to the incident, and the reason it shows, word for word
  • the output of the commands in Check it yourself, with the time you ran them and your time zone
  • the link to your check-host.net results
  • the output of systemctl status for your program, or whatever the steps on this page turned up

Then send all of it to us through Contact Us.