Mastodon upgrades change the application code that serves the web UI, background jobs, streaming API, and database schema. A server administrator should treat each release as a planned change window because release notes can require dependency updates, migrations, asset compilation, or service restarts.
Source installs normally keep application code under /home/mastodon/live with the mastodon Linux user and systemd units named mastodon-web, mastodon-sidekiq, and mastodon-streaming. Docker-based instances follow the same release-note discipline but replace the source checkout and systemd steps with the container image and Compose commands listed for the release.
The upgrade run starts with a restorable database and secret backup, records the starting version, checks out the target tag, runs only the upgrade tasks required by the skipped releases, and verifies the running version through both the CLI and the public web endpoint.
Related: How to back up a Mastodon server
Related: How to install Mastodon from source
Related: How to migrate Mastodon to a new machine
https://github.com/mastodon/mastodon/releases/tag/v4.6.2
Replace v4.6.2 with the release being installed. When skipping patch releases, read the release notes for every skipped minor version series before running any upgrade commands.
$ sudo -u mastodon pg_dump -Fc mastodon_production -f /home/mastodon/mastodon_production-before-v4.6.2.dump
Keep the matching .env.production file, local /home/mastodon/live/public/system media or object-storage snapshot, and Redis dump with the same upgrade checkpoint.
Related: How to back up a Mastodon server
$ sudo -iu mastodon
$ cd /home/mastodon/live
$ RAILS_ENV=production bin/tootctl --version Mastodon v4.6.1
$ git fetch --tags From https://github.com/mastodon/mastodon * [new tag] v4.6.2 -> v4.6.2
$ git checkout v4.6.2 HEAD is now at 70d39d3 Update FFmpeg in container images
Do not continue on an unreleased main checkout unless the instance intentionally runs a maintained fork. Mastodon release upgrades should use published git tags.
$ bundle install
Patch releases may not need dependency installation. Run this step only when the release notes include it or when Gemfile.lock changed for the target tag.
$ yarn install --immutable
Frontend dependency changes and missing node_modules can leave the web UI without current compiled assets.
$ RAILS_ENV=production bundle exec rails assets:precompile
$ SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate
If PgBouncer sits in front of PostgreSQL, run migration commands against the real PostgreSQL port. Transaction-pooling ports can break Rails advisory locks during Mastodon migrations.
$ exit
$ sudo systemctl restart mastodon-sidekiq
$ sudo systemctl reload mastodon-web
systemctl reload mastodon-web performs a phased restart for the web process. Use restart only when the release notes or local service state requires a full stop and start.
$ sudo systemctl restart mastodon-streaming
Restarting mastodon-streaming disconnects connected clients. Expect a short reconnection burst as clients reconnect or fall back to polling.
$ sudo -iu mastodon
$ cd /home/mastodon/live
$ RAILS_ENV=production bundle exec rails db:migrate
Keep this command separate from the pre-deployment migration. Some releases intentionally split schema preparation from post-restart backfills.
$ RAILS_ENV=production bin/tootctl --version Mastodon v4.6.2
$ exit
$ systemctl is-active mastodon-web mastodon-sidekiq mastodon-streaming active active active
$ curl -I -sS https://social.example.com/about HTTP/2 200 content-type: text/html; charset=utf-8 x-request-id: 1c8f6ff0-7f3a-4c20-9d8c-90a2c13b2481 ##### snipped #####
Use the real instance hostname and a page that should be reachable by anonymous users. Keep the request ID when investigating a failed response because Mastodon logs include the same identifier.