Self-host Mastodon on a no-KYC VPS
Run your own Mastodon server with handles on your domain and moderation rules you set. The timeline is chronological, with no ads and no algorithm, and it federates with the rest of the fediverse. Sign up with a generated credential and pay with crypto, card or cash.
- No email or ID
- Port 25 open
- Federates over ActivityPub
What a Mastodon server runs
Five services run before you add search, so plan on at least 4 GB.
- Web (Puma)
- The Rails app behind the website and the API every client talks to. Memory grows with WEB_CONCURRENCY, the number of worker processes.
- Sidekiq
- Background jobs: delivering posts to other servers, fetching remote posts and media, sending mail. Federation load lands here.
- Streaming
- A small Node.js service that pushes new posts to open apps and browsers as they arrive.
- PostgreSQL
- Every post, account and follow your server knows about, including copies of posts from remote accounts.
- Redis
- Job queues for Sidekiq and the home timeline of every account on the server.
- Search (optional)
- Elasticsearch for full-text search. Mastodon tests against version 7 and says OpenSearch should work, without official support. It is a Java service that can need more memory than Mastodon itself, so it usually means a bigger plan.
Which plan for which instance
| Blackbox plan | Why | |
|---|---|---|
| Just you, or a few friends | Core, 4 GB | The whole stack fits with default settings. Leave search off and prune the media cache. |
| A community of dozens | Plus, 8 GB | Room for more web workers and Sidekiq threads, or for search, and 100 GB of disk for media. |
| Hundreds of active users | Max, 16 GB | 200 GB of disk and room to split Sidekiq queues. Move media to object storage before the disk fills. |
Install Mastodon with Docker Compose
Debian 12 or Ubuntu 24.04. Point social.example.com at the server and have SMTP details ready, because the wizard asks for them.
# Debian 12 or Ubuntu 24.04, as root
curl -fsSL https://get.docker.com | sh
apt install -y git caddy
# 1. The newest release and the compose file that ships with it
git clone https://github.com/mastodon/mastodon.git /opt/mastodon
cd /opt/mastodon
git checkout $(git tag -l | grep '^v[0-9.]*$' | sort -V | tail -n 1)
docker compose pull
# 2. The wizard. Say yes to Docker and keep its defaults:
# PostgreSQL host db, user postgres, no password, Redis
# host redis. Let it prepare the database and create
# your admin account.
touch .env.production
docker compose run --rm web bundle exec rake mastodon:setup
# Under Docker it prints your configuration before it
# prepares the database: paste all of it into
# .env.production. The last thing it prints is the
# admin password, so save that too.
# 3. The containers write media as uid 991
mkdir -p public/system && chown -R 991:991 public/system
docker compose up -d
# 4. HTTPS. Streaming goes to port 4000, the rest to 3000.
cat > /etc/caddy/Caddyfile <<'EOF'
social.example.com {
encode gzip
handle /api/v1/streaming* {
reverse_proxy localhost:4000
}
handle {
reverse_proxy localhost:3000
}
}
EOF
systemctl reload caddyWhat to watch out for
The domain is permanent
LOCAL_DOMAIN becomes part of every handle, and Mastodon cannot safely change it later. For handles like @you@example.com on a server at social.example.com, set LOCAL_DOMAIN=example.com and WEB_DOMAIN=social.example.com before the first start, and redirect example.com/.well-known/webfinger to social.example.com.
The media cache fills the disk
Your server keeps copies of images and video from every account it sees. Set a media cache retention period under Administration, Server settings, Content retention, or run tootctl media remove from cron.
Mail has to work
Without working SMTP, nobody can confirm a new account or reset a password. Mail sent straight from a new IP address is often filtered as spam, so a relay is usually easier than sending from port 25 yourself.
Upgrades have steps
Every release has notes on what to run. Usually that means checking out the new tag, pulling the images and running the database migrations before you restart.
What to back up
The PostgreSQL database, the public/system folder and .env.production. The last holds the secrets, including the keys Mastodon uses to encrypt some database columns: lose it and users are logged out and two-factor login stops working. Redis matters least, since losing it costs only queued jobs and the feeds can be rebuilt with tootctl.
Your database holds every DM in the clear
Mastodon stores every post in PostgreSQL as plain text, private mentions (its direct messages) included, along with the sign-in IP addresses it records for each account. Its own docs warn that the database admins on both ends of a private mention may be able to read it. On Blackbox that database sits in memory the host cannot read, and on an encrypted disk once you turn disk encryption on.
- Set IP_RETENTION_PERIOD in .env.production to keep sign-in IPs for less than Mastodon's default of one year.
- With disk encryption on, .env.production and the keys in it sit on the same encrypted disk as the database. You type the passphrase over SSH after each reboot.
- Federation traffic and remote media fetches count toward the plan's transfer allowance, so a server that follows relays uses it faster.
Plans
| Plan | vCPU | RAM | NVMe | Traffic | Where | Price |
|---|---|---|---|---|---|---|
| Blackbox Core | 2 | 4 GB | 50 GB | 4 TB per 31 days | MontrealAmsterdamNew York City (launch pre-order)Singapore (launch pre-order) | $9.99/mo |
| Blackbox Plus | 4 | 8 GB | 100 GB | 8 TB per 31 days | MontrealAmsterdamNew York City (launch pre-order)Singapore (launch pre-order) | $19.99/mo |
| Blackbox Max | 6 | 16 GB | 200 GB | 16 TB per 31 days | MontrealAmsterdamNew York City (launch pre-order)Singapore (launch pre-order) | $39.99/mo |
| Blackbox Ultra | 8 | 32 GB | 400 GB | 32 TB per 31 days | MontrealAmsterdamNew York City (launch pre-order)Singapore (launch pre-order) | $79.99/mo |
Mastodon federates fine over IPv4 alone. If Blackbox has not opened in New York City or Singapore yet, the standard VPS line sells there, with unmetered bandwidth, no IPv6 and no memory encryption.
Questions
How much server do I need?
Blackbox Core, with 2 vCPU and 4 GB, runs a single-user server or one for a few friends. A community of dozens is more comfortable on Plus with 8 GB, and so is any server with full-text search turned on. Disk usually runs out before memory, because Mastodon keeps copies of media from other servers.
Do I need an SMTP server?
You need a way to send mail, because Mastodon emails sign-up confirmations, password resets and admin notices. The setup wizard asks for SMTP details. A transactional mail service is the simplest choice. You can also run your own mail server, since port 25 is open on Blackbox.
Can I run a single-user instance?
Yes. Answer yes to single user mode in the setup wizard. The front page then redirects to your profile and registrations stay closed. Your handle lives on your own domain, so no other server's admin can take it away.
How do I store media efficiently?
On a small server, keep media on local disk and prune the cache of remote media on a schedule. Past that, turn on S3-compatible object storage in .env.production (S3_ENABLED=true plus the bucket settings) and media stops using the server's disk.
How do I get federated quickly?
Federation starts when someone on your server follows a remote account: that account's server then sends you its new posts. Follow the people you want to read on the first day. Mastodon speaks ActivityPub, so your accounts can follow and reply to people on Pixelfed, PeerTube, Misskey, Lemmy and other fediverse software too. Relays send you far more posts, and fill the disk far faster.
Does it work with iOS and Android apps?
Yes. The official Mastodon apps and third-party ones such as Ivory, Ice Cubes, Tusky and Fedilab all accept any server address at login.
How do I back up?
Dump the database with pg_dump, copy public/system if media is stored locally, and keep .env.production with them. Schedule it with restic or borg to storage off the server.
Does Servury log my traffic?
No. We keep no traffic logs and don't log your IP or activity, and Blackbox runs no agent inside your server. Mastodon keeps its own records, such as sign-in IP addresses, in your database, and you decide how long.
Guides on this topic
- Self-Hosted Apps vs SaaS: Why Running Your Own Nextcloud, Vaultwarden, or Pi-hole Beats Trusting a Third PartyWhat changes when you run your own Nextcloud, Vaultwarden, or Pi-hole instead of trusting a SaaS provider, and how an anonymous VPS narrows the last privacy...
- Why Developers Are Self-Hosting AI Agents and LLMs Instead of Relying on Cloud AI PlatformsWhy developers are moving language models and agents onto their own VPS, keeping prompts, documents, and agent memory private instead of sending them to a...
- How to Set Up a Self-Hosted VPN with WireGuard on a VPSTen minutes from a fresh Ubuntu server to a WireGuard VPN you control: keys, config, forwarding, firewall, a phone client by QR code, and the two settings that...