Setting up Vultr S3 Object Storage on my Mastodon instance

Thursday Nov 24th 2022
3 min read

I did not setup S3 object storage while installing my own instance mut day later I was thinking that it could be easier to setup now than later. So here are couple of tips that I figured out.

Please keep in mind that you are doing this on your own risk! I do not take blame if anything goes wrong 😆

Move data to object storage

I suggest that you turn off your instance first. Then no new images will be generated. The command to do this is this:

sudo systemctl stop mastodon-*.service

Then it is time to move your existing data to your S3 object storage. These steps are from here: You also may find this article from Vultr helpful:

Install s3cmd:

sudo apt-get install s3cmd

As the mastodon user run this command (you need S3 bucket info for this):

s3cmd --configure

You can test that everything is working by creating test file and moving it to the bucket (use your own bucket name insted of BUCKET_NAME):

echo "test" > tmp.txt
s3cmd --acl-public put tmp.txt s3://BUCKET_NAME/tmp.txt

Navigate to mastodon folder:

cd ~/mastodon/live

To save some bandwidth, you can remove old remote media:

RAILS_ENV=production ./bin/tootctl media remove --days=7

Now you can move your content to the bucket (use your own bucket name insted of BUCKET_NAME):

s3cmd --acl-public sync --add-header="Cache-Control:public, max-age=315576000, immutable" public/system/ s3://BUCKET_NAME

This may take a while but after this is done your files are safely in the S3 object storage.

Edit configuration

Next you need to edit your .env.production file. Here are my S3 configurations for Vultr.


Use your own values for S3_BUCKET, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Vultr does not care about S3_REGION value. Also change S3_HOSTNAME and S3_ENDPOINT. But do not put https:// to S3_HOSTNAME. Put https:// to S3_ENDPOINT. The https:// start was a bit of a head scratcher since I got best results with mentioned values. I tried with and without but this combo worked the best.

After setting the configuration values you can start up your instance with this command:

sudo systemctl start mastodon-*.service --all


With these changes and after your instance is back up you can try to upload an image and see if it goes to S3 object storage. Mine did and it will go.

Since I have no commenting yet you can hit me up on Mastodon: @[email protected] or via email: [email protected].

If you want to help here is affiliate links!


We use Mastodon to show our comments. You only need to post a reply for the corresponding toot. We cache our comments here so it may take a couple of minutes to show up here.
Join the conversation