For various reasons, more and more people are turning away from classic social media apps to alternatives like Mastodon, which is a self-hosted alternative to Twitter. Mastodon can be used as a blogging tool for yourself, your friends and company, or as a full social network.


The social network allows to connect the feed of your server with other public Mastodon websites to show more content. Furthermore, users can freely follow users from completely different Mastodon instances and interact with posts. So even if you have a small single instance, that does not mean it needs to stay isolated.

Installing Mastodon on Exoscale

Running your own server is easy. On top it is fully compatible with Exoscale services.

Requirements for installation:

  • An Exoscale instance with Ubuntu or Debian
  • Your own (sub-)domain to be used for your Mastodon installation pointing to the Exoscale instance
  • A certificate for your domain, can be easily generated with Let’s Encrypt
  • An email delivery service or an SMTP server
  • PostgresSQL database: Self-hosted or leveraging our Managed PostgreSQL DBaaS
  • Redis®: Self-hosted or Exoscale for Caching offering

Optionally you can use an Exoscale Object Storage bucket for media files.

By using our DBaaS offering you take advantage of automatic security-critical updates and backups. Regardless of wether you install the database yourself or use our managed offerings, you should definitly consider using the Exoscale Object Storage for media files. This way you are free in terms of size of data and can store them cost-effectively.

Tips and Tricks for the installation

Create an Exoscale instance (Medium is sufficient for starters) and make sure to follow the official Mastodon documentation closely after reading the full article here on the Exoscale blog. Don’t forget to set up a security group allowing Port 80/TCP, 443/TCP for web traffic, and Port 22 exclusively for your IP for SSH.


When following the official documentation, you can disregard the chapter Setting up PostgreSQL when using our managed offering and instead continue reading the blog post. Do not forget to not install the apt package redis-server if you also plan to use Exoscale for Caching for that.

SMTP server

Outgoing connections on SMTP are not allowed by default on Exoscale, as outlined in our Security Group Documentation. Alternatively, you can use SMTP services like MailGun, SendGrid, etc.
If you just plan to do some testing without needing e-mail functionality, you can select in the installer that you want to use a local SMTP service and that you do not want to test it.

In case you just get a blank page (possibly with the Mastodon logo) after installation, most likely nginx does not have permission to enter the directory for the static files. You can quickly fix it by running chmod a+x /home/mastodon. Also make sure the check the nginx error logs in /var/log/nginx.

Preparing an Exoscale Managed PostgreSQL instance

Create a new PostgreSQL Database in the Exoscale Portal. For the beginning, you can use our hobbyist-2 offering. Make sure that the IP of the Exoscale instance is entered as IP filter and wait until the status of the database is Running.

Copy the Service-URI from the Portal and use it to connect to the database via PSQL like this:

psql postgres://avnadmin:thepassword@mastodon-exoscale-databaseuuid.aivencloud.com:21699/defaultdb?sslmode=require

Be aware that the psql command requires the postgresql and postgresql-contrib packages which can be installed by apt. When you are connected, create a new user called “mastodon” with permission to create new databases:

-- Use a securly generated random password
CREATE USER mastodon with encrypted password 'SECURERANDOMPASSWORD' CREATEDB;

The Mastodon interactive setup wizard - as explained in the official docs - will automatically create the database using the given user.

Also, create an empty postgres database. This is required as the setup checks the existence of the database to determine whether the connection to it works:

create database postgres;

When the installer asks, simply insert the hostname and the port of your database (as shown in the Exoscale Portal) and the credentials of the just-created mastodon user.

Using Exoscale Object Storage

As mentioned using an Object Storage is fully optional. Nevertheless, it is highly recommended as the amount of media in your instance can quickly rise. By connecting an S3-compatible object storage bucket you don’t have to care about increased demands and it is by far more cost-effective.


When the installer asks you about using an S3 bucket, answer that you DO NOT want to use it, as we will activate it directly in the configuration file.


You can create an Object Storage bucket in the Portal. Afterwards, you will have to head over to IAM to create a new API key for accessing it. You can restrict this key to sos and using selected buckets and then just select the bucket you created. Never share the secret with anyone.


After fully installing Mastodon head over to the folder where you installed it (usually /home/mastodon/live) and edit the file .env.production. Replace the S3_ and AWS_ directives with following ones:

S3_ENABLED=true
S3_PROTOCOL=https
S3_REGION=us-east-1
S3_ENDPOINT=https://sos-de-fra-1.exo.io
S3_HOSTNAME=sos-de-fra-1.exo.io
S3_BUCKET=your-bucket-name
AWS_ACCESS_KEY_ID=EXO1abcdefg
AWS_SECRET_ACCESS_KEY=xzyabc

Replace de-fra-1 with the zone where your bucket is located. Replace also the name of the bucket and the access/secret keys. The S3_REGION directive is ignored when specifying an endpoint. Finally issue systemctl restart mastodon*.


For testing the connectivity, you can simply upload an image while creating a post in your instance. If the upload succeeds and you see your image, the connectivity works (additionally you could check if the URL of the image points to your bucket). If you receive an error, make sure to check journalctl -u mastodon-web for the detailed error message.

Using Exoscale for Caching

Using Redis® is even easier. Simply start an instance in the Exoscale Portal, set up the IP filter and wait until it is running.


Then edit the file .env.production , delete all lines starting with REDIS_*, copy the URI of your Redis® service and insert it like this:

REDIS_URL=REDIS_URL=rediss://default:AVNS_12pass@mastodon-redis-exoscale-uuid.aivencloud.com:21700

Issue systemctl restart mastodon* again. Check mastodon-streaming for errors (i.e. systemctl status mastodon-streaming.service -n 100).

Keeping the instance running is pretty straightfoward as with the setup we have just established, the application is stateless, and data resides in the SOS for files and the rest in the database which comes with built-in backup strategies as standard on Exoscale DBaaS.

Start your Mastodon network

Installation of Mastodon is straight-forward. With the tips and tricks mentioned and following the official documentation, you are ready to start your own Mastodon network. Once you have the instance fully set up, you can try posting, uploading images or following others (even following users from other instances). If you want to go a step further you can federate your instance with the world and have a full social network timeline!