Dev.to WebDev 🛠 Dev 👁 0 📖 5 min read

How to Monitor Website Uptime and Detect Server Downtime

Hello, I'm Arthur. A website can become unavailable for several reasons. A server may stop responding, a web service may fail, or a network problem may prevent visitors from reaching the application. Even a short period

Hello, I'm Arthur.
A website can become unavailable for several reasons. A server may stop responding, a web service may fail, or a network problem may prevent visitors from reaching the application.

Even a short period of downtime can affect customer experience and business operations.

The challenge is that you cannot always monitor a website manually. A better approach is to use automated checks that detect problems and notify you when something goes wrong.

In this guide, we'll explore practical ways to monitor website uptime, check server availability, and investigate downtime using Linux tools.

1. Understand What Website Uptime Means

Website uptime refers to the period when a website is available and responding to requests.

For example, a website that remains accessible throughout the day has maintained availability during that period.

However, a server being online does not always mean the website is working correctly.

A server might respond to network requests while its application is returning errors.

That is why effective uptime monitoring should check both server availability and application responses.

2. Check Whether a Website Is Responding

One of the simplest ways to check website availability is with curl.

Run:

curl -I https://example.com

This sends an HTTP request and displays the response headers.

A successful response may look like:

HTTP/2 200
content-type: text/html

The status code 200 generally indicates that the request was successful.

Other responses can provide useful clues:

  • 301 or 302: The request is being redirected.
  • 403: Access is forbidden.
  • 404: The requested resource was not found.
  • 500: The server encountered an internal error.
  • 502: A gateway received an invalid response.
  • 503: The service is temporarily unavailable.

A single status code does not always explain the entire problem. Check the website's expected behavior and investigate the response further.

3. Check Website Response Time

A website may be available but still take too long to load.

You can use curl to measure the time required for different parts of a request.

curl -o /dev/null -s -w \
"DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTotal: %{time_total}s\n" \
https://example.com

This command reports DNS resolution time, connection time, and total request time.

If DNS resolution is slow, investigate the domain's DNS configuration.

If the connection is established quickly but the total response time is high, the application or a backend dependency may be taking too long.

Response-time monitoring helps identify performance problems before a website becomes completely unavailable.

4. Monitor Server Availability With Ping

The ping command can help check whether a server responds to network requests.

For example:

ping -c 4 example.com

This sends four ICMP requests and reports the responses.

If packets are being lost or response times are unusually high, there may be a network issue.

However, ping is not a complete website monitoring solution.

Some servers block ICMP requests while continuing to serve websites normally.

For this reason, combine network checks with HTTP monitoring rather than relying on ping alone.

5. Check Whether the Web Server Is Running

If a website is hosted on your own Linux server, check the web server service.

For Nginx:

sudo systemctl status nginx

For Apache on Ubuntu or Debian:

sudo systemctl status apache2

If the service is inactive or failed, inspect its recent logs.

For Nginx:

sudo journalctl -u nginx -n 100

For Apache:

sudo journalctl -u apache2 -n 100

Look for configuration errors, failed dependencies, or messages that appeared around the time the website became unavailable.

If the service is running but the website is still failing, investigate the application, database, and network configuration.

6. Create a Simple Automated Website Check

For a basic monitoring task, you can create a shell script that checks an HTTP response.

Create a file:

nano website-check.sh

Add:

#!/bin/bash

URL="https://example.com"

STATUS=$(curl -o /dev/null -s \
    -w "%{http_code}" \
    --max-time 10 "$URL")

if [ "$STATUS" = "200" ]; then
    echo "Website is responding successfully"
else
    echo "Website check failed. HTTP status: $STATUS"
fi

Save the file and make it executable:

chmod +x website-check.sh

Run it:

./website-check.sh

This script checks whether the website returns an HTTP 200 response within ten seconds.

For a real application, adjust the expected status code and URL to match the website's behavior.

A login page or redirect may return a different status code while still working correctly.

This is a simple starting point rather than a complete monitoring system.

7. Schedule Regular Checks

You can use cron to run a monitoring script automatically.

Open the current user's cron configuration:

crontab -e

To run the script every five minutes, add:

*/5 * * * * /path/to/website-check.sh

Replace the path with the actual location of your script.

However, running a check without recording its results or sending alerts provides limited value.

For useful monitoring, store the results or connect the check to an alerting system.

Also consider what happens if the monitoring server itself becomes unavailable.

For important websites, use an external monitoring service so that an outage on your hosting server does not disable the monitoring system as well.

8. Set Up Alerts for Downtime

Automated monitoring becomes much more useful when it can notify you about problems.

A monitoring system can send notifications through email, messaging applications, or other alerting channels.

Useful alert conditions include:

  • The website returns repeated server errors.
  • The server does not respond to HTTP requests.
  • Response times exceed an acceptable threshold.
  • A critical service stops running.
  • The website remains unavailable for a defined period.

Avoid sending alerts for every temporary failure.

For example, a single failed request may result from a brief network issue.

A monitoring system can perform additional checks before sending an alert, helping reduce unnecessary notifications.

9. Choose Hosting That Matches Your Availability Needs

Website availability depends on more than server specifications.

Network reliability, application configuration, monitoring, backups, and recovery procedures all contribute to a dependable hosting environment.

For websites and general applications, Seimaxim VPS hosting is an option to explore when evaluating server infrastructure.

For workloads that require dedicated GPU hardware, such as certain AI development and machine learning applications, Seimaxim GPU dedicated servers provide another infrastructure option to consider.

Regardless of the hosting environment, maintain an independent monitoring system and a clear recovery plan.

Final Thoughts

Website uptime monitoring helps identify availability problems before they affect too many users.

Start with basic HTTP checks, monitor response times, and review server logs when something goes wrong.

For production websites, use automated monitoring with external checks and reliable alerts.

A consistent monitoring process can help reduce downtime, improve troubleshooting, and make website operations more reliable.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.