How to Run Your Own Mastodon Instance on a VPS

Mastodon Instance

In our digital world where everybody shares almost every moment on Social Media, Mastodon is a cool alternative to platforms like Twitter (now called X). But what’s Mastodon? Well, it’s like a do-it-yourself Twitter that isn’t all about collecting your data – and the best about it: Because it’s open-source it’s completely free. This article will show you what Mastodon is, how it’s different from Twitter, and why it’s awesome to have your own Mastodon space. Plus, we’ll help you set up your own Mastodon on a Linux computer.

The Decentralized Idea Behind Mastodon

At its heart, Mastodon isn’t just another social media platform; it’s a testament to the power of decentralization and community-driven development. Imagine a sprawling network of interconnected instances, each acting as an independent node, collectively forming the vast universe of Mastodon. Instead of a single monolithic platform with a central governing body, Mastodon is an ecosystem of micro-communities, where each instance can be tailored to its unique user base, content policies, and governance structure. This decentralized model inherently promotes user agency, privacy, and customization, fostering a digital landscape that reflects the diverse range of voices and interests in the real world.

Mastodon vs. Twitter

In the world of social media, Mastodon stands out for its decentralized approach and focus on giving users more control. This is quite different from platform X, which used to be called Twitter. While X has a lot of users and is well-known, it’s tangled up in challenges like keeping user data private, not being clear about how their algorithms work, and having a central authority control all activity on the platform. On the other hand, Mastodon’s way of working is more community-driven and puts users in charge. X’s algorithms can make certain posts more visible, which leads to worries about people only hearing similar opinions and biases in the algorithms. In Mastodon, posts just show up in the order they were made, which keeps things open and encourages real conversations. Plus, Mastodon’s setup lets users and administrators customize the platform, build local communities, and handle content rules themselves.

Benefits of Hosting Your Own Mastodon Instance

When it comes to diving into the Mastodon social network, you’ve got choices: hop onto an existing instance or set up your own instance. Let’s break it down. Joining an existing instance can be like moving into a ready-made neighborhood – you’re part of an existing community right away. But there are limits to how much you can customize things. On the flip side, hosting your own instance gives you a world of benefits. You get to be the boss of your Mastodon world – you can make it look and work just how you want. You’re in charge of the rules, which means you can make it a friendly and cozy space for you and your friends, free from any unwanted noise. Plus, your data is in your hands, so no worries about privacy.

Creating Your Own Mastodon Server

As we delve deeper into this article, you’ll learn how to turn this vision into reality by installing your very own Mastodon instance on a Linux server with Debian 11. This journey will equip you with the tools and insights needed to navigate the technical aspects of setting up and maintaining a self-hosted Mastodon instance, allowing you to carve out your digital haven in the vast expanse of the decentralized social web.


Before you dive into setting up your own Mastodon instance, there are a few key prerequisites to bear in mind. Firstly, you’ll need a server with Debian 11 or Ubuntu 20.04 on it to host your Mastodon instance. A suitable domain is also required. If you need a fitting server, we got you covered as well! Depending on the number of users and general activity on your instance you may need different amounts of RAM, CPU-cores and storage space. Our VPS M SSD offers a great starting tier for your Mastodon journey. We also offer VPS with different configurations here.

Installation of Mastodon on Debian 11

Let’s roll up our sleeves and get into the nitty-gritty of installing Mastodon on a Debian 11 Linux server. Follow these steps to bring your instance to life:

Update System Packages

Begin by updating your system’s package list and upgrading any existing packages:

apt update 
apt upgrade

Install System Repositories:

Make sure curl, wget, gnupg, apt-transport-https, lsb-release and ca-certificates is installed first because these packages are required to continue:

apt install -y curl wget gnupg apt-transport-https lsb-release ca-certificates 

Install NodeJS

Now it’s time to install NodeJS to handle Mastodon’s JavaScript dependencies:

curl -sL | bash - 

Install PostgreSQL

As the database software PostgreSQL is required. Install it with these two commands:

wget -O /usr/share/keyrings/postgresql.asc 
echo "deb [signed-by=/usr/share/keyrings/postgresql.asc] $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/postgresql.list 

Install Other Required Packages

Because Mastodon is a complex piece of software, many packages are required for it to run. Install them all together with this big command:

apt install -y \ 

  imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core \ 

  g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf \ 

  bison build-essential libssl-dev libyaml-dev libreadline6-dev \ 

  zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev \ 

  nginx redis-server redis-tools postgresql postgresql-contrib \ 

  certbot python3-certbot-nginx libidn11-dev libicu-dev libjemalloc-dev

Enable Yarn

Enable Yarn with this command:

corepack enable 

And set Yarn’s version:

yarn set version classic 

Install Ruby

Because .rbenv must be installed for a single Linux user we will create a Mastodon user with disabled login before we can start with the actual installation of Ruby:

adduser --disabled-login mastodon 

Now lets switch to the mastodon user with this command:

su – mastodon 

Now lets start with the actual installation of Ruby by executing these commands, command after command:

git clone ~/.rbenv 
cd ~/.rbenv && src/configure && make -C src 
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc 
echo 'eval "$(rbenv init -)"' >> ~/.bashrc 
exec bash 
git clone ~/.rbenv/plugins/ruby-build 
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.2.2 

Don’t worry: This step will take AGES!

rbenv global 3.2.2 
gem install bundler --no-document 

Before proceeding with the setup of PostgreSQL we will switch back to the root user with the following command:


Setting up PostgreSQL

It’s time to create a database for our Mastodon instance. This can be done with these commands:

sudo -u postgres psql 

And now exit PostgreSQL:


Setting up Mastodon

Switch to the mastodon user once again:

su – mastodon 

And download and install the required files:

git clone live && cd live 
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1) 
bundle config deployment 'true' 
bundle config without 'development test' 
bundle install -j$(getconf _NPROCESSORS_ONLN) 
yarn install --pure-lockfile 

Now start the installation setup with this command:

RAILS_ENV=production bundle exec rake mastodon:setup 

Here you will create a configuration file, run the asset precompilation, create the database scheme and create your admin account as well as set a few other options e.g. if you want to enable registrations on your instance. The setup process is very straightforward.

Setting Up a Reverse Proxy with Nginx

cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon 
nano /etc/nginx/sites-available/mastodon 

Add the following two lines after this part:

image 6.png
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; 

Now save the file with [CTRL] [O] and exit the editor with [CTRL] + [X] 

It should look like this:

image 7.png

Now activate the config with this command:

ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodon 
systemctl reload nginx 

Install an SSL Certficiate

To make our Mastodon instance more secure we will install a free SSL certificate with certbot. This will install Let’s Encrypt certificates for our instance. Have you ever asked yourself what SSL certificates are and how they – and the whole process actually works? Check out our detailed guide on SSL here.

certbot --nginx -d [your-domain]

Start the Mastodon Service

cp /home/mastodon/live/dist/mastodon-*.service /etc/systemd/system/ 
$EDITOR /etc/systemd/system/mastodon-*.service 
systemctl daemon-reload 
systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming 

Now wait one minute until everything is set up and then enter your domain in the browser.

You will be greeted by this homescreen:

image 8.png

Congrats! You’ve successfully installed your own Mastodon instance on your server. Have fun inviting friends and customizing your social media experience. Learn more about how to customize Mastodon on their official documentation here.

See Also: Experience Our for Free VPS Hosting: Enjoy a 30-Day Trial with Risk-Free Servers


Bare Metal Dedicated Servers

A single tenant, physical server allowing you full access to its resources

Read More

Cloud VPS

The cheapest way to get your own independent computing instance.
Read More

Cloud VDS

Virtualized server platform hosted on enterprise-grade physical servers

Read More

10 Gbps Unmetered Servers

Zomev offers high bandwidth dedicated servers up to 20Gbps.

Read More


Receive the latest news, updates and offers. You can unsubscribe at any time.


Receive the latest news, updates and offers. You can unsubscribe at any time.

zomiv footer logo


Support Hours: 24x7x365
Sale Office Hours: M-F, 7AM-5PM EST

We accept the following:

download (6)



© Copyright 2024, All Rights Reserved by DataCamp Int Limited.

Zomev is a trading name of DataCamp Int Limited. Registered Office: 71-75 Shelton Street, Covent Garden,
London, United Kingdom, WC2H 9JQ.Registered Number 15527709. Registered in England and Wales.



Receive the latest news, and offers. You can unsubscribe at any time.

This is a staging enviroment

Please tell us more about yourself.

Complete the form below and one of our experts will contact you within 24 hours or less. For immediate assistance contact us.

In order to finalize your application, please read and accept our Terms and Conditions*.


Complete the form below and one of our experts will contact you within 24 hours or less. For immediate assistance contact us.

We promise not to sell, trade or use your email for spam. View our Privacy Policy.