Get an email alert when your website goes down
The usual answer is to sign up for an uptime monitoring service. On Val Town it's one cron-triggered val: fetch your URL on a schedule, remember the last known status in blob storage, and send yourself an email with std/email only when the status changes — one email when the site goes down, one when it recovers.
The monitor
Because the last status is stored in blob storage, you never get repeat alerts while the site stays down. The first run only records a baseline, so remixing it never sends a surprise email.
Set it up
- Remix this template — click the Remix button in the top right corner.
- In
monitor.ts, changeURL_TO_MONITORto your website's URL.
That's it: no API keys, no environment variables, no signup for a monitoring
service. To test it, point URL_TO_MONITOR at a URL that 404s and click
Run on monitor.ts twice — the first run records the baseline, the
second one emails you.
Notes
- Alerts go to your Val Town account email — that's where std/email delivers by default.
- The template checks every five minutes (
*/5 * * * *). On the free plan crons run at most once every 15 minutes, so change the schedule to*/15 * * * *(or upgrade to Pro for up to once a minute). - A response is counted as up when
res.okis true (status 200–299), and as down on any other status or a network error.
Next steps
- Cron reference — schedule types and limits
- std/email reference — subject, attachments, and sending limits
- Website uptime tracker — community variations on the same idea
Last updated