Back to all templates
Mastodon logo

Mastodon

Application2048MB+ RAM

Decentralized social network (Twitter alternative)

socialfediversetwitter-alternativeactivitypub

Deploy Mastodon in 3 Steps

1

Connect Your VPS

Add your server credentials to Server Compass

2

Select Mastodon

Choose from our template library

3

Deploy & Configure

Fill in settings and click Deploy

No Docker knowledge required
Step-by-step deployment guide

Deploy Mastodon on a VPS with Server Compass

Use the Mastodon template in Server Compass to deploy the web, streaming, Sidekiq, PostgreSQL, and Redis services, then verify the web health endpoint and public UI.

About 10 minutesBrowser verified
1
Step 1

Open the server Apps tab

Select the tutorial-vps VPS, open the Apps tab, and start a new app deployment. Keep sensitive server details hidden before capturing or sharing screenshots.

Server Compass Apps tab before creating a Mastodon app
2
Step 2

Choose an app template

Click New App and choose the template deployment path so Server Compass can load the built-in catalog.

Choosing to deploy an app from a Server Compass template
3
Step 3

Search for Mastodon

Use the template picker search to find Mastodon in the Server Compass template catalog.

Searching for Mastodon in the Server Compass template picker
4
Step 4

Select the Mastodon template

Choose the Mastodon template. Server Compass fills the Mastodon web, streaming, Sidekiq, PostgreSQL, Redis, setup migration service, persistent media volume, and required secrets.

Mastodon template selected in Server Compass
5
Step 5

Review the Mastodon settings

Confirm the app name, local domain, web domain, generated secrets, web port, and streaming port. In this run, the app was named mastodon-demo and used host web port 4300.

Reviewing Mastodon project settings and compose services
6
Step 6

Deploy Mastodon

Review the generated compose settings, confirm the Mastodon web and streaming ports are available, and click Deploy.

Reviewing Mastodon domain, secret, and port settings before deployment
7
Step 7

Watch the deployment progress

Keep the deployment modal open while Server Compass uploads the compose file, pulls the Mastodon images, runs database setup, starts the web, streaming, and Sidekiq services, and verifies the stack.

Server Compass deploying the Mastodon template on the VPS
8
Step 8

Confirm Mastodon is running

After deployment finishes, return to the Apps tab and confirm the Mastodon app is marked Running with its application URL available.

Mastodon template running in the Server Compass Apps tab
9
Step 9

Open Mastodon in the browser

Open the application URL in a browser. The Mastodon web UI confirms the instance is reachable before you create the first administrator and configure federation requirements.

The deployed Mastodon web UI loaded in a browser

After Mastodon Opens

  • Create the first Mastodon owner account with `tootctl accounts create USERNAME --email [email protected] --confirmed --role Owner`.
  • Replace the tutorial sslip.io hostname with a real domain before inviting users.
  • Configure HTTPS and SMTP before federation, signups, or notification email.
  • Review moderation, registrations, server rules, and federation settings before opening the instance.
  • Back up PostgreSQL and the Mastodon media volume before relying on the instance.

Verified Result

The Mastodon `/health` endpoint returned OK and the public web UI loaded through the configured sslip.io domain.

Mastodon deployment questions

What does the Mastodon template deploy?

It deploys Mastodon web, streaming, Sidekiq, PostgreSQL, Redis, a one-shot database setup service, and persistent media storage.

Which port did the tutorial use?

The tutorial used host web port 4300, which maps to the Mastodon web service on container port 3000.

Does Mastodon need setup after deployment?

Yes. Create the first owner account, configure a real domain, HTTPS, SMTP, and moderation settings before using it as a production federated server.

Should this become a blog post?

No. The deployment guide should live on the Mastodon template detail page and be linked from the reusable template deployment docs page.

DIY Deployment

Self-Host Mastodon with Docker

Take the DIY route and deploy Mastodon on your own server using Docker.

1

Remote into Your Server

Initiate a secure shell connection to your server using the command below.

terminal
# Connect to your VPS
ssh root@your-server-ip

# Or with a specific SSH key
ssh -i ~/.ssh/your-key root@your-server-ip

First time? Docker required! Install it with: curl -fsSL https://get.docker.com | sh

2

Create the App Directory

Organize your deployment by creating a dedicated project folder.

terminal
# Create and navigate to project directory
mkdir -p ~/apps/mastodon
cd ~/apps/mastodon
3

Write Your docker-compose.yml

Create a new docker-compose.yml file and paste this configuration:

docker-compose.yml
services:
  mastodon:
    image: tootsuite/mastodon:latest
    ports:
      - "3000:3000"
    environment:
      - LOCAL_DOMAIN=<your-local-domain>
      - SECRET_KEY_BASE=<your-secret-key>
      - OTP_SECRET=<your-otp-secret>
      - DB_HOST=db
      - DB_USER=mastodon
      - DB_PASS=<your-db-password>
      - DB_NAME=mastodon
      - REDIS_HOST=redis
    command: bundle exec rails s -p 3000
    volumes:
      - mastodon_data:/mastodon/public/system
    restart: unless-stopped
    depends_on:
      - db
      - redis

  sidekiq:
    image: tootsuite/mastodon:latest
    command: bundle exec sidekiq
    environment:
      - LOCAL_DOMAIN=<your-local-domain>
      - SECRET_KEY_BASE=<your-secret-key>
      - OTP_SECRET=<your-otp-secret>
      - DB_HOST=db
      - DB_USER=mastodon
      - DB_PASS=<your-db-password>
      - DB_NAME=mastodon
      - REDIS_HOST=redis
    volumes:
      - mastodon_data:/mastodon/public/system
    restart: unless-stopped
    depends_on:
      - db
      - redis

  streaming:
    image: tootsuite/mastodon:latest
    command: node ./streaming
    ports:
      - "4000:4000"
    environment:
      - LOCAL_DOMAIN=<your-local-domain>
      - SECRET_KEY_BASE=<your-secret-key>
      - DB_HOST=db
      - DB_USER=mastodon
      - DB_PASS=<your-db-password>
      - DB_NAME=mastodon
      - REDIS_HOST=redis
    restart: unless-stopped
    depends_on:
      - db
      - redis

  db:
    image: postgres:16-alpine
    environment:
      - POSTGRES_USER=mastodon
      - POSTGRES_PASSWORD=<your-db-password>
      - POSTGRES_DB=mastodon
    volumes:
      - postgres_data:/var/lib/postgresql/data
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    volumes:
      - redis_data:/data
    restart: unless-stopped

volumes:
  mastodon_data:
  postgres_data:
  redis_data:
Configurable Options
PORTHost port(default: 3000)
LOCAL_DOMAINDomain
SECRET_KEYSecret key
OTP_SECRETOTP secret
DB_PASSWORDDB password
4

Launch the Containers

Start the services and tail the logs to verify startup.

terminal
# Spin up containers
docker compose up -d

# Verify deployment
docker compose ps

# Check logs for errors
docker compose logs -f
5

Open Firewall Ports

Open the required port in your firewall to allow access.

terminal
# Allow the application port through firewall
sudo ufw allow 3000/tcp
sudo ufw reload

# Access your app at:
# http://your-server-ip:3000
Skip the Terminal

Want the easy way? Try Server Compass.

Forget SSH and YAML files. Deploy Mastodon visually with Server Compass in just a few clicks.

  • Visual config editor
  • Instant deployment
  • Automatic HTTPS
  • Smooth updates
  • Live monitoring
  • Quick rollbacks
Download Server Compass$29 one-time • Lifetime license

After Deployment

After deploying Mastodon with Server Compass, complete these steps to finish setup

1

Run: tootctl db:setup

2

Create admin account

3

Configure SMTP

Need help? Check out our documentation for detailed guides.

Mastodon FAQ

Common questions about self-hosting Mastodon

How do I deploy Mastodon with Server Compass?

Simply download Server Compass, connect to your VPS, and select Mastodon from the templates list. Fill in the required configuration and click Deploy. The entire process takes under 3 minutes.

What are the system requirements for Mastodon?

Mastodon requires a minimum of 2048MB RAM. We recommend a VPS with at least 4096MB RAM for optimal performance. Any modern Linux server with Docker support will work.

Can I migrate my existing Mastodon data?

Yes! Server Compass provides volume mapping that allows you to import existing data. You can also use standard Mastodon backup and restore procedures.

How do I update Mastodon to the latest version?

Server Compass makes updates easy. Simply click the Update button in your deployment dashboard, and the latest Mastodon image will be pulled and deployed with zero downtime.

Is Mastodon free to self-host?

Mastodon is open-source software. You only pay for your VPS hosting (typically $5-20/month) and optionally Server Compass ($29 one-time). No subscription fees or per-seat pricing.

Ready to Self-Host Mastodon?

Download Server Compass and deploy Mastodon to your VPS in under 3 minutes. No Docker expertise required.

Download Server Compass