If your website goes down at 2 AM., you want to be the first to know, not the last. That is what uptime monitoring is for: something outside your server checks the site every few minutes, records whether it answered, and tells you (and your visitors) when it did not. Most people reach for a hosted service, but the free plans of these tools tend to come with limits on how often they check, how many sites you can add, or how much you can customize the public status page.
In this guide I’ll show you how to build your own free uptime monitoring system and a public status page on Cloudflare’s free plan, using Cloudflare Workers, Cron Triggers and the D1 database. It checks your website over HTTPS every minute, opens and resolves incidents automatically, keeps a year of uptime history and serves a clean status page on your own subdomain. No server, no container, no monthly bill. I use exactly this setup for SysOpsTechnix (you can see it live at status.sysopstechnix.com), but everything below is generic, so any web developer can use it for website uptime monitoring on a blog, a SaaS app, an API or a client’s website.
TL;DR: One Cloudflare Worker runs on a one-minute Cron Trigger, sends an HTTPS request to each URL you list, checks the status code, the page content and the response time, and saves the result in a D1 (SQLite) database. Three failed checks in a row open an outage incident; two good checks close it. The same Worker renders the status page at status.yourdomain.com. All of it fits comfortably inside Cloudflare’s free limits.

What You Will Build: Features of This Uptime Monitor
Before we start, here is what the finished system does. Everything in this list is included in the single Worker file you’ll copy later in this post.
- One-minute HTTPS checks for one or more URLs (website, API, landing page) using a Cloudflare Cron Trigger.
- Smart check rules: each check verifies the HTTP status code, optionally confirms that a piece of text exists on the page, enforces a 10-second timeout and flags slow responses.
- Automatic incidents: an outage incident opens after 3 failed checks in a row, a “degraded performance” incident after 5 slow checks, and both resolve themselves after 2 good checks.
- Public status page with a status banner, 90 daily bars, uptime for 7 days, 30 days, 90 days and 12 months, recent incidents and a full incident history.
- Maintenance notices and manual incident updates through a small admin API protected by a secret token.
- A failed-check log (90 days) so you can trace short blips with simple SQL queries.
- Optional Slack or Discord alerts when an incident opens or resolves.
- Dark mode, mobile layout and a JSON endpoint (
/api/status) out of the box.
Why Build Your Own Uptime Monitoring on Cloudflare?
Hosted monitors such as UptimeRobot or Atlassian Statuspage are good products, and if you are happy with them there is no reason to switch. I built my own for three reasons: I wanted one-minute checks for free, I wanted the status page on my own subdomain with my own design, and I wanted the raw data in a database I can query. Cloudflare Workers make that possible without running a server, because Cloudflare runs the code for you on a schedule and on every page request.
| Typical hosted free plan | This Cloudflare Workers setup | |
|---|---|---|
| Check interval | Often several minutes on free plans | Every minute |
| Status page | Hosted page, branding and custom domains often paid | Your own design on your own subdomain |
| Data access | Dashboard and exports | Full SQL access to every check in D1 |
| Incidents | Automatic | Automatic, plus manual updates and maintenance |
| Server to maintain | None | None (serverless) |
| Cost | Free tier, paid upgrades | $0 within Cloudflare’s free limits |
| Check locations | Usually several regions | One location per check (see Limitations) |
The trade-off is that you own the uptime monitoring code. The good news is that it is a single JavaScript file of about 550 lines with no dependencies, so it is easy to read and change.
Architecture: How the Uptime Monitor Works

The whole system is made of four Cloudflare building blocks, all available on the free plan:
- Cron Trigger: runs the Worker’s
scheduled()handler every minute (* * * * *). See the Cron Triggers documentation. - Cloudflare Worker: a small JavaScript program. Its
scheduled()function performs the checks; itsfetch()function serves the status page, the JSON API and the admin API. - D1 database: Cloudflare’s serverless SQLite database. It stores one row per monitor per day (
daily_stats), the live state of each monitor (state), incidents and their updates, the failed-check log and a cached snapshot of the page data (meta). The Worker creates these tables itself the first time it runs. - Custom domain and WAF: the Worker is served on
status.example.comwith an automatic certificate, and a free rate limiting rule protects it from abuse.
Two design choices keep it fast and cheap. First, instead of logging every single check, the Worker updates one row per monitor per day with running totals (checks, failures, slow responses, total response time). Second, the status page doesn’t calculate a year of uptime on every visit: the Worker rebuilds a snapshot every five minutes (or immediately when an incident changes) and each page view reads just two database rows.
How the Uptime Checks Decide: Up, Slow or Down
Every minute, each monitor goes through these steps in order. The first step that fails decides the result:
- Response within 10 seconds. No answer in time, or a DNS, TLS or connection error, means down (for example “Timed out after 10000 ms”).
- Expected status code. Anything other than the codes you list (default
200) means down, for example “HTTP 503”. - Expected content. If you set
bodyIncludes, the page must contain that text, otherwise the check is down with “Expected content missing”. This catches broken pages that still return 200, such as a blank page, a PHP fatal error, a WordPress “critical error” screen or a hosting “account suspended” page. - Response time. If everything passed but the first response took longer than 4 seconds, the check is slow; otherwise it is up.
The checker adds a random _sc query parameter and a Cache-Control: no-cache header to every request. That bypasses page caches (Cloudflare, WordPress cache plugins, Varnish), so the monitor tests your real origin server instead of a cached copy that might hide an outage.
| Event | Rule (default) | What the status page shows |
|---|---|---|
| Outage | 3 down checks in a row (about 3 minutes) | Red “Service outage” incident |
| Degraded performance | 5 slow checks in a row | Amber “Degraded performance” incident |
| Recovery | 2 good checks in a row | Incident marked resolved with an update |
| Maintenance | Posted manually through the admin API | Blue “Maintenance” entry |
A single failed check never opens an incident, which avoids false alarms from one-off network blips, but it is still counted in the uptime percentage and logged in the check_failures table. Uptime is simply (total checks − failed checks) ÷ total checks; slow checks still count as up.
Is This Uptime Monitoring Really Free? Cloudflare Free Plan Limits
Yes, for a realistic number of monitors. Here are the free plan limits that matter for uptime monitoring from Cloudflare’s Workers limits and D1 pricing pages, and what this setup uses with one monitor:
| Free plan limit | Allowance | This setup (1 monitor) |
|---|---|---|
| Workers requests | 100,000 per day | About 1,440 cron runs + your page views |
| CPU time | 10 ms per invocation | Well under; waiting for HTTP responses doesn’t count as CPU |
| Subrequests | 50 per invocation | 1 per monitor per run |
| Cron Triggers | 5 per account | 1 |
| D1 rows written | 100,000 per day | About 4,300 per day (3 writes per run) |
| D1 rows read | 5 million per day | 2 per page view + about 120,000 per day for the 5-minute snapshots |
| D1 storage | 5 GB | Well under 1 MB per year |
Each extra monitor adds roughly two database writes per minute, so you can watch around 30 URLs before you get near the daily write limit. If you ever exceed a free limit, Cloudflare doesn’t bill you: requests fail until the daily reset at midnight UTC. Limits change over time, so check the linked pages before you rely on the numbers.
Prerequisites for This Uptime Monitoring Setup
- A free Cloudflare account.
- A domain whose DNS is managed by Cloudflare, if you want the status page on
status.yourdomain.com. Without one you can still use the free*.workers.devaddress. The websites you monitor can be hosted anywhere. - Either the Cloudflare dashboard only, or Node.js 18+ to use Wrangler, Cloudflare’s command-line tool. I show both ways.
Step 1: Create the D1 Database
In the Cloudflare dashboard go to Storage & databases → D1 SQLite Database → Create Database, name it uptime-status, keep the automatic location and click Create.

If you prefer the command line, Wrangler does the same thing and prints the database ID you’ll need in Step 2:
Create the database with Wrangler
npm create cloudflare@latest uptime-status -- --type=hello-world --lang=js --git=false --deploy=false
cd uptime-status
npx wrangler login
npx wrangler d1 create uptime-status
You don’t have to create any tables. The Worker runs CREATE TABLE IF NOT EXISTS for all of them on its first request, so a brand-new, empty database is all it needs.
Step 2: Create the Worker and Its Configuration
Dashboard: go to Compute → Workers & Pages → Create → Start with Hello World!, name the Worker uptime-status and click Deploy. You will replace the Hello World code in Step 3.

Wrangler: replace the generated wrangler.toml (or wrangler.jsonc) with the following. Paste your database ID from Step 1 and change the domain to your own.
wrangler.toml
name = "uptime-status"
main = "src/worker.js"
compatibility_date = "2025-09-01"
workers_dev = false
routes = [
{ pattern = "status.example.com", custom_domain = true }
]
[triggers]
crons = ["* * * * *"]
[[d1_databases]]
binding = "DB"
database_name = "uptime-status"
database_id = "PASTE-YOUR-DATABASE-ID-HERE"
What each part does:
mainpoints to the Worker file you’ll create in Step 3.workers_dev = falseturns off the public*.workers.devaddress, so the status page is only reachable on your own domain.routeswithcustom_domain = truemakes Cloudflare create the DNS record and the TLS certificate forstatus.example.comautomatically. See Custom Domains.crons = ["* * * * *"]runs the checks every minute.[[d1_databases]]binds the database to the Worker asenv.DB. The binding name must be exactlyDB.
Step 3: Add the Uptime Monitoring Worker Code
The complete Worker is a single JavaScript file of about 550 lines with no dependencies, so I keep it on GitHub where it is easier to read, copy and update: lakindu93/cloudflare-workers-uptime-monitor (MIT licence). The repository also contains an example wrangler.toml and a README.
With Wrangler, clone the repository instead of the project from Step 1 (it already has src/worker.js and wrangler.toml), then put your database ID and domain in wrangler.toml:
git clone https://github.com/lakindu93/cloudflare-workers-uptime-monitor.git
cd cloudflare-workers-uptime-monitor
In the dashboard, open src/worker.js on GitHub, click Raw (or the copy icon), copy everything, then open your Worker, click Edit code, select everything in worker.js, paste the code and click Deploy.

The CONFIG block at the top of src/worker.js (excerpt)
// ─── 1. Configuration ─────────────────────────────────────────────────────
const CONFIG = {
siteName: "Example", // shown in the banner: "Example: All systems operational"
siteUrl: "https://example.com",
footerLinks: [
{ label: "Home", href: "https://example.com/" },
{ label: "Privacy policy", href: "https://example.com/privacy-policy/" },
],
failThreshold: 3, // consecutive failed checks before an outage incident opens
recoveryThreshold: 2, // consecutive good checks before the incident resolves
slowThresholdMs: 4000, // a 200 response slower than this counts as "slow"
slowConsecutive: 5, // consecutive slow checks before a degraded incident opens
timeoutMs: 10000, // no response within this time = down
historyDays: 90, // days shown in the bar chart and incident list
// What to monitor. Don't rename an id once it's live (its history is stored under it).
monitors: [
{
id: "website",
name: "example.com",
description: "Main website",
url: "https://example.com/",
expectStatus: [200],
bodyIncludes: "</html>", // text that must be on a working page, e.g. your footer copyright
},
// { id: "api", name: "API", description: "Public REST API", url: "https://api.example.com/health", expectStatus: [200] },
],
};
Get the complete code: src/worker.js in the cloudflare-workers-uptime-monitor GitHub repository.
The file is split into seven numbered sections so you can find your way around:
- Configuration: site name, footer links, thresholds and the list of monitors. This is the only part most people need to edit.
- Database schema: the tables, created automatically.
- The checks:
checkMonitor()runs one HTTPS check;runChecks()saves the results, opens and resolves incidents and sends alerts. - Status data: calculates uptime percentages and the daily bars and saves the page snapshot.
- The status page: HTML, CSS and a little JavaScript. It has no external dependencies, so it loads fast and has nothing to break.
- Admin API: create incidents or maintenance windows and post updates.
- Entry points:
fetch()for web requests andscheduled()for the Cron Trigger.
Configure your monitors
Edit the CONFIG block at the top. Each monitor needs a unique id (don’t rename it later, because its history is stored under that id), a display name and the url to check. Everything else is optional:
Example: a WordPress site and an API
monitors: [
{
id: "website",
name: "example.com",
description: "Main website",
url: "https://example.com/",
expectStatus: [200],
bodyIncludes: "All rights reserved", // text from your footer
},
{
id: "api",
name: "API",
description: "Public REST API",
url: "https://api.example.com/health",
expectStatus: [200, 204],
timeoutMs: 5000, // per-monitor override
slowThresholdMs: 1500, // per-monitor override
},
],
For bodyIncludes, pick text that appears on every working page but not on error pages. Text from the footer is ideal because it only shows up when the whole page has rendered. On SysOpsTechnix I use the copyright line “All rights reserved”. The match is case-sensitive, so copy it exactly from your page source.
Step 4: Bind D1, Add the Cron Trigger and Deploy
Wrangler: everything is already in wrangler.toml, so a single command deploys the code, the binding, the Cron Trigger and the custom domain:
Deploy
npx wrangler deploy
Dashboard: open the Worker and go to Settings.
- Under Bindings, click Add binding → D1 database, set the variable name to
DB, choose youruptime-statusdatabase and click Add Binding.

- Under Trigger events → Cron triggers, click Add, choose Minute(s), enter
1and click Add.

Step 5: Put the Status Page on Your Own Subdomain
In the dashboard, open the Worker’s Domains tab, click Add Domain, select your zone and type status as the subdomain. Be careful not to leave the subdomain empty: that would attach the Worker to your root domain and replace your website. Cloudflare creates the DNS record and certificate for you; if a status DNS record already exists, delete it first.
On the same tab, switch off the workers.dev production URL (and leave preview URLs off). Your status page is then only reachable through your custom domain, which sits behind your zone’s security settings.

Step 6: Verify the First Uptime Checks
Wait a minute or two, then open https://status.example.com/. The banner should say “All systems operational” and “Status checked just now”, and today’s bar should be green. The earlier days show as striped (“No data”) until history builds up. From the command line you can check the JSON endpoint and watch the Worker’s logs live:
Check the status API and stream logs
curl -s https://status.example.com/api/status | head -c 400
npx wrangler tail uptime-status
You can also look straight at the database: open D1 → uptime-status → Console and run:
Current state of every monitor
SELECT service_id, status, fail_count, last_ms, last_error,
datetime(last_checked/1000, 'unixepoch') AS last_check_utc
FROM state;
status should be up and last_error empty. If you see an error, jump to the troubleshooting section below.
The Status Page UI Explained
The status page is deliberately simple and generic, so it fits any brand. Change siteName and footerLinks in CONFIG, and adjust the colours in the CSS variables at the top of the <style> block if you want to match your site.
- Status banner: green “All systems operational”, amber “Degraded performance”, red “Partial outage” or “Major outage”, or blue “Under maintenance”, plus how long ago the last check ran.
- 90-day bar chart: one bar per UTC day, coloured by the worst incident on that day. Hover or tap a bar to see its date and incidents. Phones show the last 30 or 60 days.
- Uptime table: uptime for 7 days, 30 days, 90 days and 12 months per monitor, with its current status.
- Recent incidents: every incident from the last 90 days with its timeline of updates;
/historylists all of them. - Automatic refresh, dark mode and mobile layout: the page refreshes its data every minute and follows the visitor’s light or dark setting.

Secure Your Uptime Monitoring Status Page on the Free Plan
A status page has to be public, and every visit counts as a Worker request against your free daily allowance. Nobody can run up a bill on the free plan, but someone flooding the page could use up the 100,000 daily requests and take the status page (and the checks) offline until midnight UTC. Three small steps prevent that:
- Turn off workers.dev (done in Step 5, or
workers_dev = falseinwrangler.toml) so the Worker is only reachable through your zone. - Add a rate limiting rule. In your zone go to Security → Security rules → Create rule → Rate limiting rule. Requests blocked by the WAF never reach the Worker, so they don’t count against your limit. The free plan includes one rate limiting rule.
- Set an admin token if you want to use the admin API (next section). Without
ADMIN_TOKENthe admin endpoints are disabled.
Rate limiting rule expression
(http.host eq "status.example.com")
Set Requests to 30, Period to 10 seconds, Action to Block and Duration to 10 seconds. A real visitor never comes close to 30 requests in 10 seconds.
Post Maintenance Windows and Manual Incident Updates (optional)
Automatic incidents cover outages, but sometimes you want to tell visitors something yourself, for example planned maintenance or the root cause of an outage. First add a secret called ADMIN_TOKEN with a long random value (Settings → Variables and Secrets → Add, type Secret), or run npx wrangler secret put ADMIN_TOKEN.
Schedule maintenance (shows as blue)
curl -X POST https://status.example.com/api/admin/incidents \
-H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" \
-d '{"title":"Database upgrade","impact":"maintenance","message":"Short interruptions are possible.","service_ids":["website"],"starts_at":"2026-12-01T20:00:00Z"}'
Add an update to an incident (“resolved” closes it)
curl -X POST https://status.example.com/api/admin/incidents/INCIDENT_ID/updates \
-H "Authorization: Bearer $ADMIN_TOKEN" -H "Content-Type: application/json" \
-d '{"status":"identified","message":"The hosting provider confirmed a failed load balancer."}'
Valid impacts are outage, degraded and maintenance; valid statuses are investigating, identified, monitoring, scheduled, in_progress and resolved. Incident IDs are in /api/status, or run SELECT id, title FROM incidents ORDER BY started_at DESC in the D1 console. POST /api/admin/run-checks runs a check cycle immediately, which is handy right after a deploy.
Optional: Slack or Discord alerts
Create an incoming webhook in Slack or Discord and save its URL as a secret named WEBHOOK_URL. The Worker then posts a message whenever an incident opens, escalates or resolves. The message body includes both text (Slack) and content (Discord), so the same code works for either.
Troubleshooting Uptime Monitoring with SQL Queries
Because every result lives in D1, troubleshooting is mostly a matter of running the right query in D1 → your database → Console (or with npx wrangler d1 execute uptime-status --remote --command "..."). These are the queries I use most.
Recent failed and slow checks, with the exact error
SELECT datetime(at/1000, 'unixepoch') AS utc, service_id, outcome, error, ms
FROM check_failures
ORDER BY at DESC
LIMIT 50;

Uptime and average response time per day
SELECT day, service_id, checks, failures, slow,
ROUND(100.0 * (checks - failures) / checks, 3) AS uptime_pct,
total_ms / checks AS avg_ms
FROM daily_stats
ORDER BY day DESC
LIMIT 14;

Uptime over the last 30 days per monitor
SELECT service_id,
ROUND(100.0 * (SUM(checks) - SUM(failures)) / SUM(checks), 3) AS uptime_30d
FROM daily_stats
WHERE day >= date('now', '-30 days')
GROUP BY service_id;
Do failures cluster at a certain hour? (UTC)
SELECT strftime('%H', at/1000, 'unixepoch') AS hour_utc, COUNT(*) AS failures
FROM check_failures
WHERE outcome = 'down'
GROUP BY hour_utc
ORDER BY failures DESC;
Open incidents and their latest update
SELECT i.id, i.title, i.impact, i.status,
datetime(i.started_at/1000, 'unixepoch') AS started_utc,
(SELECT message FROM incident_updates u WHERE u.incident_id = i.id
ORDER BY created_at DESC LIMIT 1) AS latest_update
FROM incidents i
WHERE i.status != 'resolved';
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Page says “Status checked not yet” and every bar is striped | The Cron Trigger isn’t running or the D1 binding is missing | Check Settings → Trigger events and Bindings; the binding name must be DB. Run npx wrangler tail and wait for the next minute. |
| Every check fails with HTTP 403 or 503 | Your own WAF, Bot Fight Mode or a security plugin blocks the checker | Set a CHECK_TOKEN secret and add a WAF custom rule that skips security for requests whose X-Status-Check header equals that token, or allow the UptimeMonitor/1.0 user agent in your plugin. |
| “Expected content missing” while the site looks fine | bodyIncludes text doesn’t match the HTML exactly | View the page source and copy the text exactly; the match is case-sensitive and HTML entities count. |
| Single “Timed out after 10000 ms” entries | The origin was briefly slow (backups, cron jobs, cache rebuilds) | Use the hour-of-day query above to find a pattern; check your server’s scheduled jobs. Single blips never open incidents. |
| Lots of “slow” entries | Checks bypass the page cache, so they measure a full uncached page build | Raise slowThresholdMs, or point the monitor at a lighter health-check URL. |
| “Error 1027” on the status page | The daily free request limit was reached | Make sure the rate limiting rule is active and workers.dev is off; the limit resets at midnight UTC. |
| Uptime looks wrong after renaming a monitor | History is stored under the monitor id | Change name, never id. To remove an old monitor’s data: DELETE FROM daily_stats WHERE service_id = 'old-id'; (and the same for state). |
Tip: D1 has a built-in point-in-time restore called Time Travel. Before you run any DELETE in the console, note the current time; if something goes wrong you can restore the database to that moment from the Time Travel tab.
Limitations of This Uptime Monitoring Setup
- One vantage point. Each scheduled run executes in one Cloudflare location, so this is not multi-region monitoring. It tells you whether your site is reachable from Cloudflare’s network, which is a good proxy for most visitors.
- Same provider. If Cloudflare itself has an outage, the checks and the status page can go down with it. For critical sites, pair this with a second, external uptime monitoring service that only sends you an email.
- One-minute resolution. Outages shorter than a minute may go unnoticed, and an incident needs three failed checks (about three minutes) to open. You can lower
failThresholdif you prefer faster alerts and accept more false alarms. - HTTPS checks only. The Worker checks URLs over HTTP(S). It doesn’t ping servers, test raw TCP ports or monitor databases directly; expose a small health-check URL for those.
FAQ: Free Uptime Monitoring with Cloudflare Workers
Is uptime monitoring with Cloudflare Workers really free?
Yes. A one-minute check of a single website uses about 1,440 Worker requests and a few thousand D1 writes per day, far below the free plan’s 100,000 requests and 100,000 writes. You only pay if you choose to upgrade to a paid Workers plan.
Does my website need to be hosted on Cloudflare?
No. The monitor can check any public URL, wherever it is hosted. Only the status page’s custom domain needs a zone on Cloudflare; without one, you can serve the status page on a free *.workers.dev address.
Can I use this for WordPress uptime monitoring?
Yes, and the content check makes it more reliable than a plain status-code check. WordPress can return HTTP 200 with a blank page or a “There has been a critical error on this website” message. Set bodyIncludes to text from your theme’s footer and those pages will be reported as down.
How is this different from UptimeRobot or Statuspage?
It is self-hosted on serverless infrastructure: you get one-minute checks, your own status page design and full SQL access to your data at no cost, but you maintain the code and you get a single check location. Hosted tools add multi-region checks, phone and SMS alerts and team features.
Can I build a self-hosted status page without a server?
That is exactly what this setup is. The status page is rendered by the same Worker that runs the checks, so there is no VPS, Docker container or database server to maintain.
Conclusion
With one Cloudflare Worker, a D1 database and a Cron Trigger, you get free website uptime monitoring with one-minute checks, automatic incidents, a status page on your own subdomain and a database you can query whenever something looks odd. It took me an afternoon to set up, and within its first days it had already logged short timeouts on SysOpsTechnix that a monitor checking every five minutes could easily have missed. You can see it live at status.sysopstechnix.com. The complete code is on GitHub; a star there helps other developers find it.
