Getting an alert when your site goes down: a simple uptime check

To know your site is down before a customer tells you, you need something that visits it from outside, now and then, and warns you if it does not answer. The rule that decides everything: the watcher cannot be on the same server as the thing it watches. If the server goes down, the watcher goes with it and nobody tells anybody.

Where to put the watcher

Option How it works Watch out for
An external monitoring service There are several; they visit your address from various places and warn you by e-mail or message. Check on each one’s site what is free and how often it checks.
A script on another server of yours A cron job on another plan or a VPS makes the request and warns you. It must really be on another machine.
n8n on a VPS A workflow with a scheduler, an HTTP request and a notice. Only works if the VPS is not the same one as the site.

A check script, step by step

1 Make the request and read the code. With curl -s -o /dev/null -m 15 -w "%{http_code}" https://asuaempresa.ao/ you get only the reply number, giving up after 15 seconds. 200 is good health.
2 Compare it with what you expect. If the code is not 200, or the request does not answer in the time given, that is an alert.
3 Check the content, not only the code. An error page can also answer 200. Look in the text for a word that only exists when the site is fine.
4 Try twice before you warn. A passing failure does not deserve an alert. Repeat after half a minute and warn only if it fails again.
5 Send the notice to a channel you see. An e-mail to a mailbox you never open is no use. A message on your phone works: alerts to Telegram.
6 Schedule the check every few minutes, not every second. In cron the % sign needs a backslash: \%{http_code}. See the cron checklist.
An alert that fires for everything stops being read. If you get twenty false alarms you will ignore the twenty-first, which is the real one. Adjust the number of tries and the frequency until it warns only when it is worth it.

When the alert arrives, the first step is to work out what kind of failure it is: website errors explained: 500, 403, 404, 508 and what to do. If the failure is the server’s and not your site’s, open a ticket with the exact time and what you saw.

Also watch what breaks silently: the certificate about to expire, the domain about to lapse, the contact form. A weekly check on each saves you surprises.

Want a server of your own to run watchers and automations? See the VPS plans.

See the VPS servers

SEE ALSO

Website errors explained: 500, 403, 404, 508 and what to do

Error 503 and the rest of the 5xx family: what they are, and where to start

Cron jobs: what they are for and how to create one

VPS servers

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from 5.940,00 Kz/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?