How to check if a website is online
Ever wonder how to check if a website is still working, without having to load up the website and manually check every few minutes? In this article, we'll go over the various ways to check if a website is online.
Table of contents:
- Why do websites go offline?
- How to check if a website is online
- How to monitor your website
- How to monitor keywords on a website
In its simplest form, a website is a collection of files that are hosted on a server. When you visit a website, your browser makes a request to the server, and the server responds with the files for the website. More recently, websites have started to use APIs to fetch data to generate webpages from other servers, but the core concept is the same.
When we say a website is online, we mean that a server is responding (with the expected files) to requests from the Internet.
Things aren't that simple when a website is offline, though. There are a few different ways a website can be offline:
If the server is down (that is, not running), it can't respond to requests from the Internet, so the website will be unavailable.
If the server takes too long to respond, the browser will give up and show an error. This often happens when a server is overloaded with requests, or if the server makes a request to another server, which itself is overloaded.
Smaller companies tend to run into this issue by hosting their websites on small servers without a CDN in front, as the servers often don't have enough RAM/CPU to handle the number of requests they receive.
In my experience, this is the most common way a website can be offline.
If the domain name is not pointing to the server, the server won't receive any requests from the Internet.
You might run into this issue when launching your website, as in the worst case, it can take a few hours for the domain name to start pointing to the server. This can also happen when changing domain name registrars.
If the domain name has expired, the domain name registrar will stop pointing the domain name to the server. This is an avoidable problem however, and I wrote about how to avoid losing your domain name a while back.
There are a few ways to check if a website is online, some requiring more manual work than others:
The most obvious way to check if a website is online is to visit it using your browser. If you can see the website, it's online. If you can't, it's probably offline (assuming your internet connection is fine).
This method isn't bulletproof, as a website appearing online for you doesn't guarantee that it's online for everyone else.
If you're technically-minded, you can use a command line tool like
curl in your Terminal to check if a website is online.
If you see a bunch of HTML, the website is online. If you see an error, the website is offline.
If you want to take it further, you can turn the above command into a script that runs every few minutes, and sends you an email if the website is offline:
#!/bin/bashif curl -s https://www.google.com | grep -q "html"; thenecho "Website is online"elseecho "Website is offline" | <command to send email goes here>fi
If you're running a business, you probably don't have time to check if your website is online every few minutes. You also don't want to have customers email/call/text you frantically that your website is down, and they're unable to use your product.
This is where website uptime monitoring services like OnlineOrNot come in. It checks if your website is online up to every 30 seconds, and if it's not, you'll immediately get a notification via email, SMS, Slack, or Discord.
To monitor a website with OnlineOrNot, all you need is the URL.
I tend to give my checks memorable names, so I can easily tell what they're for, and I set the check to run from around the world, so I can be sure the website is online for everyone:
After adding the check, you will start to see the results in the dashboard:
Monitoring for keywords on OnlineOrNot requires one extra step.
In a check's advanced settings I set the 'Text to search for' to look for the keyword I'm interested in (it also supports HTML, if you want to check for a specific HTML element):
Once setup, OnlineOrNot will send you an alert whenever that keyword is not found on the website.
OnlineOrNot is a monitoring service for websites, APIs, web apps, and scheduled jobs/repeating tasks.