# How do I self-host Mastodon on a VPS?

> Self-host Mastodon 4.7 on a Linux VPS: requirements, install steps, SMTP on port 587, media cleanup, backups and plan sizes. Paid in crypto, no KYC.

- URL: https://vpswithcrypto.com/mastodon-on-a-vps/
- Last updated: 2026-11-03
- Publisher: VPS With Crypto (https://vpswithcrypto.com)

What a Mastodon server runs, the domain choice you cannot undo, the install steps of the official guide, outgoing mail with port 25 closed, the media cache that fills disks, the four things to back up, and which plan to start on.

**Quick answer — What do I need to self-host Mastodon on a VPS?**

A domain you will never change, Ubuntu 24.04 or Debian 13, PostgreSQL 14 or later, Redis 7, Node.js 22 and Ruby, nginx with a certificate, and a mail provider on port 587 or 465. Mastodon 4.7.4 was the current release on 3 November 2026. On VPS With Crypto, start a small instance on Mega (2 vCPU / 6 GB / 120 GB) and size for disk first: the cache of remote media keeps growing.

## What does a Mastodon server run?

**Five services, which a small instance keeps on one VPS:**

- **mastodon-web**: Puma, serving the web interface and the REST API (Ruby on Rails).
- **mastodon-sidekiq**: background jobs such as deliveries to other servers, media processing, notifications and mail.
- **mastodon-streaming**: the Node.js streaming API behind live timelines.
- **PostgreSQL**: the main database.
- **Redis**: cache and job queue.

The README of Mastodon 4.7.4, released on 29 October 2026, lists Ruby 3.3+, PostgreSQL 14+, Redis 7.0+, Node.js 22+ and FFmpeg 5.1+. The official install guide targets Ubuntu 24.04 and Debian 13, and both are images you can pick at checkout: Debian 13, Debian 12, Ubuntu 24.04 LTS, Ubuntu 22.04 LTS, AlmaLinux 10, Rocky Linux 10. nginx sits in front of everything and serves the static files.

## Which domain settings can never change?

**`LOCAL_DOMAIN`, the domain in every handle.** Mastodon's configuration reference says it cannot be safely changed later: other servers would treat your existing accounts as new ones. Choose it before the setup wizard runs.

`WEB_DOMAIN` is the option for handles on one domain and the server on another. With `LOCAL_DOMAIN=example.com` and `WEB_DOMAIN=mastodon.example.com`, users are `@alice@example.com` while the site runs on the subdomain. The main domain must then redirect `/.well-known/webfinger` to the Mastodon host, with CORS headers. It cannot be safely changed once set either.

## What are the install steps?

The order of the official guide, condensed. Copy each command from the guide itself: it follows every release.

1. **Prepare the VPS** — Key-only SSH, updates, and a firewall that lets in 22, 80 and 443 only. The first ten minutes guide covers it.
2. **Add the package sources** — NodeSource for Node.js 24 and the PostgreSQL project's apt repository, then install nodejs, redis-server, postgresql, nginx, certbot, python3-certbot-nginx and the build and media libraries the guide lists. Turn on Yarn with corepack enable.
3. **Create the mastodon user and Ruby** — adduser --disabled-password mastodon, then rbenv and ruby-build as that user, and RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install for the Ruby version the release asks for.
4. **Create the database role** — In psql as the postgres user: CREATE USER mastodon CREATEDB;. The guide uses local ident authentication, so no password is needed.
5. **Get the code** — Clone the repository into ~/live, check out the latest stable v4.7 tag, then run bundle install and yarn install.
6. **Run the setup wizard** — RAILS_ENV=production bin/rails mastodon:setup asks for the domain, database, Redis and SMTP details, writes .env.production, compiles the assets and creates the schema.
7. **Certificate and nginx** — certbot certonly --nginx -d example.com, then copy dist/nginx.conf to /etc/nginx/sites-available/mastodon, set your domain, enable it, and run chmod o+x /home/mastodon so nginx can read the assets.
8. **Start the services** — Copy dist/mastodon-*.service to /etc/systemd/system/, run systemctl daemon-reload, then systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming.

## How do I send Mastodon email with port 25 closed?

**Point Mastodon at a mail provider's submission port.** Outbound port 25 is closed on every VPS and is not opened on request; send mail through a mail provider on port 465 or 587. Mastodon defaults `SMTP_PORT` to 25, so an instance left on the default cannot send confirmation or password-reset mail, and new users never finish signing up.

Give the provider's details to the setup wizard, or edit `.env.production` afterwards and restart `mastodon-web` and `mastodon-sidekiq`. On 587, the default `SMTP_ENABLE_STARTTLS=auto` upgrades the connection with STARTTLS. On 465, add `SMTP_SSL=true`, which switches Mastodon to SMTP over TLS.

*Mail settings in /home/mastodon/live/.env.production*

```bash
SMTP_SERVER=smtp.your-provider.example
SMTP_PORT=587
SMTP_LOGIN=mastodon@example.com
SMTP_PASSWORD=app-password-from-the-provider
SMTP_FROM_ADDRESS="Mastodon <notifications@example.com>"
# port 465 instead: SMTP_PORT=465 and SMTP_SSL=true
```

## Where does the disk go, and how do I keep it in check?

**Into the cache of remote media.** Every post from another server that reaches your timelines brings its images and videos with it. `tootctl` cleans the cache: `media remove` deletes cached attachments from other servers older than 7 days by default, and `preview_cards remove` deletes link-preview thumbnails older than 180 days by default, with a warning against going under 14. Run both from a timer and check `media usage` once a week.

Uploads can also go to S3-compatible object storage instead of the VPS disk. Mastodon's backup guide then leaves those files to the storage provider.

*As the mastodon user*

```bash
cd /home/mastodon/live
RAILS_ENV=production bin/tootctl media usage
RAILS_ENV=production bin/tootctl media remove --days 7
RAILS_ENV=production bin/tootctl preview_cards remove --days 30
```

## What do I back up?

**The four items of Mastodon's backup guide, copied off the VPS.** No plan includes backups, so keep your own copy of anything that matters.

- **PostgreSQL**, with `pg_dump`: accounts, posts and follows, the data that matters most.
- **`.env.production`**: the application secrets. Lose them and users are logged out, two-factor authentication stops working and Web Push subscriptions break.
- **`public/system`**: uploaded files, when they live on the VPS disk.
- **`/var/lib/redis/dump.rdb`**: the only Redis file the guide asks for.

A backup that stays on the same disk does not survive the loss of the server. The same four items are what you carry when you [move to another VPS](https://vpswithcrypto.com/migrate-a-linux-vps/ "How do you migrate a Linux VPS to a new host without losing data?").

## Which plan fits a Mastodon instance?

**Mastodon's documentation sets no minimum for RAM or disk.** The rows below come from the five services it runs and from the media cache, not from load tests. The vCPU of every plan are shared: they are scheduled on physical cores that neighbouring VPS also use. The RAM and NVMe space of your plan are reserved for your VPS only. Byte is left out: 1 vCPU / 2 GB / 40 GB is better spent on a [WireGuard endpoint](https://vpswithcrypto.com/wireguard-on-a-vps/ "How do you set up WireGuard on a Linux VPS for your own devices and servers?") or a [small website](https://vpswithcrypto.com/host-a-website-on-a-vps/ "How do you host a website or blog on your own VPS?").

*Sizes are vCPU / RAM / NVMe. Prices are per month on a 12-month term, the same in all six cities.*

| Plan | Size | Fits | 12-month price a month |
| --- | --- | --- | --- |
| Kilo | 2 vCPU / 4 GB / 65 GB | A single-user instance with media on object storage; little room to spare | $4.49 |
| Mega | 2 vCPU / 6 GB / 120 GB | A single-user or family instance with media on the VPS | $6.75 |
| Giga | 4 vCPU / 8 GB / 160 GB | A small community, with more Sidekiq threads and a longer media cache | $13.50 |
| Tera | 8 vCPU / 24 GB / 400 GB | A larger community that keeps its media on the server | $20.62 |

**Start your instance on a VPS paid in crypto** Ubuntu 24.04 or Debian 13, root over SSH, in New York, Dallas, Los Angeles, London, Amsterdam or Frankfurt. No KYC: signing up and paying take no identity document, no selfie, no card and no phone number. [See plans and prices](https://vpswithcrypto.com/pricing/ "How much does a VPS With Crypto server cost per month?")

## Questions about Mastodon on a VPS

### Can I run Mastodon with Docker instead of from source?

Yes. The Mastodon repository ships Docker and docker-compose configurations. The domain rule, the SMTP settings, the media cleanup and the four backup items stay the same.

### Can I move my Mastodon instance to another domain later?

No. Mastodon's configuration reference says `LOCAL_DOMAIN` cannot be safely changed: remote servers would see your accounts as new ones. Moving to another VPS on the same domain is fine.

### Why does my new instance send no confirmation emails?

`SMTP_PORT` defaults to 25. Outbound port 25 is closed on every VPS and is not opened on request; send mail through a mail provider on port 465 or 587. Set `SMTP_PORT=587`, or `465` with `SMTP_SSL=true`, and restart the web and Sidekiq services.

### How much disk will Mastodon use?

It depends on how many accounts your users follow on other servers, because their media is cached locally. Run `tootctl media usage` to measure it and `tootctl media remove` on a timer to keep the cache at a fixed age.

### Do I need object storage?

No. Uploads and the cache can stay on the NVMe disk of the VPS. Object storage keeps a growing instance off the local disk and takes the uploads out of your own backups.

## Sources

1. [Installing from source (Ubuntu 24.04 or Debian 13)](https://docs.joinmastodon.org/admin/install/) — Mastodon (read 2026-11-03)
2. [Preparing your machine (SSH, firewall)](https://docs.joinmastodon.org/admin/prerequisites/) — Mastodon (read 2026-11-03)
3. [Configuring your environment (LOCAL_DOMAIN, WEB_DOMAIN, SMTP variables)](https://docs.joinmastodon.org/admin/config/) — Mastodon (read 2026-11-03)
4. [Backing up your server](https://docs.joinmastodon.org/admin/backups/) — Mastodon (read 2026-11-03)
5. [Using the admin CLI (tootctl media, tootctl preview_cards)](https://docs.joinmastodon.org/admin/tootctl/) — Mastodon (read 2026-11-03)
6. [Mastodon v4.7.4 README: requirements](https://github.com/mastodon/mastodon/blob/v4.7.4/README.md) — Mastodon gGmbH on GitHub (read 2026-11-03)
7. [Mastodon releases (v4.7.4, 29 October 2026)](https://github.com/mastodon/mastodon/releases) — GitHub (read 2026-11-03)

---

VPS With Crypto: VPS With Crypto sells Linux KVM VPS in New York, Dallas, Los Angeles, London, Amsterdam and Frankfurt, paid in crypto with no ID upload. The business behind it is DomaineGoat LLC, registered in Panama. A plan costs the same in all six cities, and on a 12-month term it is priced at least 25% under a named comparable plan, chosen among 34 no-KYC crypto hosts and read on 3 November 2026.
