I've been on Mastodon for over a year now, and I felt like it was time to move on. What do I mean by move on? Well, until recently, I've been hanging out on
mastodonapp.uk as my "home" instance but, me being the self-hosting nerd that I am, I knew that this was not a permanent home for me as the ultimate goal would be to eventually host my own instance.
So that is exactly what I did.
I was in the process of organising my existing setup with my homelab and I managed to free up and some Raspberry Pi 4's. Rather than just leaving them to gather dust, I decided to repurpose one of them to host my Mastodon server.
However, what I was about to embark upon was a week of trail and error in order to get things working properly. It certainly wasn't as straightforward as I would have imagined and there is still more that needs to be done.
This is what I learnt from setting up my own instance.
Federation does not take place immediately
One of the key features of Mastodon and ActivityPub is the ability to interact with users across different instances. The big instances (like
mastodon.social)receive loads of activity from external instances. The same could be said for my previous instance,
So when I set up my own instance, I was disappointed when I found out that I couldn't see any external activity at all. Because of this, I couldn't use features like trending hashtags and posts.
I just assumed that I would be able to see everything immediately after the setup. It turns out that I was wrong. It often takes hours (or even days in my case) in order to start seeing activity from external peers.
Thankfully, I found a couple of ways of speeding this up.
Follow and interact with others
If you migrated from a different instance, chances are you're already following a bunch of accounts. By simply following and interacting with those on different instances, this will be enough to get Mastodon to start establishing new peers.
tootctl domains crawl
Perhaps one of the most exhaustive, and resource intensive, solutions would be to use
tootctl domains crawl to crawl the known fediverse.
The idea is that if you already have a few peers connected to your instance, you can run this tool in your
/live directory to expand your peers by examining the peers of their peers.
If you have no peers at all, then you can provide a domain of a popular server (i.e. mastodon.social) and search its peers like so:
tootctl domains crawl mastodon.social
Join a Relay
If you're really impatient, like me, you can subscribe to what is known as a "relay server". It essentially acts as a bridge between your server and others. The idea is that it makes it easier for your server to discover new instances.
Here's a complete list of relay servers to join.
The downside of this is that it takes time to get approved (I'm still waiting on some) however, one service I found particularly helpful is FediBuzz
With FediBuzz, you can connect with others based around a particular instance, or particular hashtags you're interested. I tried this with the following:
Clear your cache!
One of the biggest headaches I've experienced with setting up my server is the need to continually clear the cache.
I tried all manner of different stuff.
- I changed file and directory permissions. Nope.
- I added
RAILS_SERVE_STATIC_FILES=trueto my config file. Nope.
- I recompile static files using
RAILS_ENV=production bundle exec rake tmp:cache:clearand
RAILS_ENV=production bundle exec rails assets:precompile. Nope.
Nothing appeared to work.
After many hours of head scratching, it turns out that my setup was fine all along. It was just a Cloudflare and browser caching issue. Because I use Cloudflare and its tunnels service to expose my services to the web, I found that I needed to tweak my existing caching rules and then it worked!
Increase your swap file and give yourself plenty of storage
Because I was using a 4GB Raspberry Pi (which is more than enough for a personal, single user instance btw), I found that in order to manage the initial compile stage, I needed to increase my swap file size to ensure that it had enough resourced to enure that the script completed.
It's also worth mentioning that you will properly want to use a sizeable SD card to store everything. I'm using a 64GB SD, and I'm beginning to see that this is not going to be enough.
Ask the community for help
One of my favourite things about Mastodon is how friendly and responsive the people are when reaching out for help.
I initially reached out to the community to see if it's possible to run Mastodon on a Raspberry Pi, as well as asking what they did to set things up and troubleshooting. I found that overall, people are more than happy to help out.
I've had a really positive experience as, the chances are, you're not the first person to attempt this. One user (who I will not name) was even prepared to share config files with me. How nice.
Now that I've eventually managed to get my own server up and running, I feel like I've gained a little more independence and control regarding how I handle my data.
It's worth mentioning that I'm still relatively new to the Fediverse and there is still so much more I need to learn. I still find myself tweaking my setup to ensure that it's in 100% working order.
With that said, I hope that this rather lengthy blog post is of some encouragement to others who are in a similar situation to myself. The learning never stops.
My next challenge is to implement some form of backup and restore system should something disastrous happen.