Articles / Self-Hosting

  • mastodon
  • self-hosting
  • fediverse
  • reliability
  • sysadmin
  • bus-factor

Why Your Self-Hosted Mastodon Instance Dies When One Admin Burns Out

Most single-admin Mastodon servers do not crash. They go quiet for a fortnight, then a certificate expires, then a security release goes unapplied, then the disk fills. The software was fine. The human holding it together ran out of spare attention.

This is a reliability problem with a person in the failure path. Treat the admin like any other component: it has a failure rate, and you can design around it.

The slow failures arrive in a predictable order

A neglected instance does not fail all at once. It fails along calendars and thresholds, roughly like this:

  • Days: the media cache grows and the disk fills, because remote media is cached locally by default.
  • Weeks: the Sidekiq queues back up, so posts deliver late and then not at all.
  • Weeks to months: a security release lands and is not applied.
  • Quarterly or yearly: a TLS certificate, a domain registration or a mail provider credential expires.

None of these needs expertise to fix. They need someone to notice, which is exactly what burnout removes.

Why a dead instance is worse than a dead blog

A static site that goes offline loses readers. A Mastodon instance loses identities. Your handle is user@yourdomain, and followers on other servers follow that exact address.

Account migration, where you move to another server and followers are carried over, is initiated from the old server. If the old one is already gone, you can no longer issue the move. You are starting from scratch, with whatever follow and block lists you exported earlier.

Other servers will also keep trying to deliver to you for a while. Mastodon tracks repeated delivery failures and eventually treats the domain as unavailable. The practical effect for your users is a slow, confusing fade, not a clear announcement.

Quick detour: why the queue is the canary

Hang on, why does the queue back up first? Mastodon does almost everything asynchronously through Sidekiq, a background job processor backed by Redis. Delivering your post to every follower's server is a job. Fetching remote media is a job. Sending email is a job.

So when something is wrong, whether that is a full disk, a stuck database connection or a failing mail relay, the web UI often still loads. The jobs just stop completing. If you only check "does the front page load", you will miss it for days.

Make the boring checks automatic

The cheapest improvement is to stop relying on memory. Anything that expires or fills up gets an external check that pages someone else, or at least emails you somewhere you read.

A certificate check from a machine that is not the server:

echo | openssl s_client -connect social.example.org:443 \
  -servername social.example.org 2>/dev/null \
  | openssl x509 -noout -enddate

Wrap that in a cron job on a different host and alert when the date is under 14 days away. Do the same for the domain registration and the disk usage of the media volume.

For the cache, schedule the built-in cleanup instead of doing it by hand:

RAILS_ENV=production bin/tootctl media remove --days=7

Run it from a systemd timer or cron as the Mastodon user. Check the tootctl help for your version before relying on the flags, as they have changed between releases.

Updates are the real risk, so shrink them

Security releases are where a tired admin hurts most, because the upgrade is the most involved routine task. It usually means pulling a new version, running migrations, recompiling assets and restarting services in the right order.

Three things make that survivable:

  1. Write the upgrade steps down as a runbook, exactly as you run them, including the order of restarts.
  2. Take a database dump immediately before each upgrade, and know where it lands.
  3. Subscribe to the project's release announcements on an address that reaches more than one person.

If the runbook only exists in your head, it does not exist on the day you cannot be reached.

A second admin is not optional, but it need not be heavy

"Get a co-admin" sounds like advice for large communities, but it applies to small ones as well. The minimum is one trusted person who can do four things:

  • log in to the server over SSH
  • log in to the domain registrar and DNS provider
  • restore from backup
  • post an announcement from the instance account

They do not need to be an expert. They need credentials held somewhere safe (a password manager's shared vault works) and a runbook they can follow. Test it once while you are healthy, not during a crisis.

Backups are only half the answer

A database dump gets the posts back. It does not restore the server's secret keys, or the environment file holding them. Without the .env.production secrets, restored accounts and sessions will not behave properly, and you could lose the ability to sign in with existing two-factor setups.

So back up three things together: the PostgreSQL database, the environment file, and the user-uploaded media if it is stored locally. Then restore them to a scratch machine at least once. A backup you have never restored is a guess.

Plan the shutdown before you need it

Sometimes the right answer is to stop. Doing that well is kind to users, and it takes a few weeks of notice and a short written plan:

  1. Announce the closing date well ahead, from the instance account and by email.
  2. Tell users to export their follows, blocks and posts and to migrate to a new server while yours still works.
  3. Keep the domain registered for a good while afterwards, so nobody else can impersonate old handles.

A planned exit loses far fewer identities than a silent one. If you take only one thing from all this: write down what "I am done" looks like while you still enjoy running the thing.