Register now for better personalized quote!

I'm running my own Mastodon server on a Raspberry Pi. Here's what I've learned

Jan, 09, 2023 Hi-network.com
Sabrina Ortiz/

I've used Twitter every single day for the last 15 years or so. It's been an immeasurable tool that's helped me do my job, but more importantly, it was a networking tool that helped me get new freelancing jobs. I'd imagine about 80% of my freelancing work has come from people I've interacted with or met on Twitter. 

Special Feature

The Tech Trends to Watch in 2023

Learn about the leading tech trends the world will lean into over the next 12 months and how they will affect your life and your job.

Read now

But, as I'm sure most are aware, Twitter has been a bit of a mess lately. And it's not somewhere I want to use my energy or spend any time on. But like the rest of my Twitter-addicted friends, I can't just quit Twitter. 

I need something to replace it, and right now, it looks like Mastodon is that thing.

I technically have had a Mastodon account since 2018 when it first launched, but that sat dormant until a couple of months ago when I signed back in, just in case. 

Also: Ditching Twitter? Here's how to get started on Mastodon

Mastodon is confusing in that you have to pick a server to join. And each server can have slightly different rules, moderation policies, or even themes. But that also means you can start your own Mastodon server. 

And so, I decided that if I'm going to truly move away from Twitter, I want to own my entire Mastodon experience. I don't want to worry about the server I've joined having an admin go rogue, or not being able to secure enough funding to keep running. I want to be my own admin, and it'll be up to me to keep the server running. 

At first, I tried looking for a hosting provider I could pay a small monthly fee to in exchange for them hosting my Mastodon instance. Unfortunately, it seemed all of those providers have stopped taking new signups because they're overwhelmed. 

So I started looking for ways to run a Mastodon server at home. At first I looked into using a Docker container on mySynology NAS , but ultimately decided to repurpose a spareRaspberry Pi 4 I had lying around doing nothing. I had previously used it to run a Pi Hole ad blocker and Homebridge to control non-HomeKit devices using HomeKit. Both of those tasks are now handled by my NAS, and so began the process of trying to install Mastodon on a Pi. 

Also: How I solved one of my biggest Raspberry Pi headaches

Below I'll walk you through what ended up working for me, linking out to a guide that I followed and providing some pieces of advice for those who also decide to give it a try. 

How it's going so far

Before I cover how to start your own instance, let me just say that after three weeks of having my own Mastodon server, complete with a custom domain name, I have no regrets. There's something liberating about knowing that I own the entire experience, including all of my data -- and it's all stored in my basement. 

Recommends

The best web hosting services

We take a look at some of the best web hosting providers and help you understand how to choose the best for your needs.

Read now

Once the server was up and running, I was able to use Mastodon just as I had over at Mastodon.social and Journa.host. In fact, I have redirected both accounts to my self-hosted account @[email protected]. Moving your account from one server to another isn't a horrible process, but it could be improved (See "How do I move to a different server?"). 

The transition meant that I kept all of my followers, which showed up in batches over a couple of hours, but had to go back and manually follow everyone I was following before. It took an hour or so for all of my followers to fully transfer over. However, I think if I would have created an archive of my old account -- which includes my posts, follows, boosts and likes -- I could have imported that information into my account and switching severs wouldn't have been as much of a hassle.  

Outside of migrating accounts, the rest of the experience has been hiccup-free. I've really been impressed with how fast my timeline loads, including posting photos and videos, even as the number of people I follow continues to climb, increasing what's loaded in my personal timeline, but also in the local and federated feeds that it creates. 

The Pi 4, thus far, has been more than capable of running a single-user instance. I'd imagine it'd have no issues running with more than a couple of users, but I wouldn't push it much further than that. 

What you'll need

  • ARaspberry Pi 4 with at least 2GB of memory.
  • A microSD card. The bigger, the better. I used a 256GB card. 
  • A USB-C power supply for the Raspberry Pi 4.
  • A domain of your own. I bought one using Cloudflare, but you can buy one wherever you want.
  • A few hours set aside to install, troubleshoot, and install again (if needed).

The worst part about wanting to do any sort of Raspberry Pi project right now is that you simply can't find them in stock. They've been in short supply for some time and the listings on Amazon are overpriced , to say the least. If you can be patient, I suggest using rpilocator.com's stock tool to find a Pi 4 for a reasonable price.

Also: What do all those microSD and SD card numbers and letters mean?

 Ideally, you have a Raspberry Pi sitting idle that you can repurpose, as I did.   

There are a lot of guides, but here's the one I followed

I'm not smart enough to figure out the steps required to install a Mastodon server on a Pi, so I used a guide. I actually tried a few guides, but the guide on PiMyLifeUp is ultimately the one that worked for me. 

It's very long, but thorough and explains each step. After you get Raspbian up and running on your Pi, you can connect to it via SSH and just copy and paste the commands found in the guide. 

Also: Why a Raspberry Pi 5 in 2023 could be a disaster

There's only one section I didn't follow, and that's the Node.JS section. Instead of installing the latest version, which I think is 18.x, I installed the latest version of Node.JS 16. I had some issues with the installation early on and a friend (who was also building his own instance on a Pi) said that Node.JS 18 wouldn't work. I can't confirm that, but I can say that using Node.JS 16 did work. 

So, when you get to the section for installing Node.JS, run these commands instead of following the secondary PiMyLifeUp guide. 

curl -sL https://deb.nodesource.com/setup_16.x  sudo bash -

sudo apt install nodejs

node -v

Once you're done with that part of the installation, go back to the PiMyLifeUp guide and follow the rest of it. 

The entire process takes roughly an hour, maybe 90 minutes, with the Ruby installation taking the most time. Be patient; let the Pi complete each step before moving on to the next. 

Dealing with the domain and port forwarding on your home network

Screenshots by Jason Cipriani/

The hardest part of the entire installation process was dealing with the domain, security certificates, and port forwarding. I have a basic idea of how to do all of that, but when it comes down to it, I get lost pretty easily. 

If you're like me, I suggest reaching out to a friend or even to support at your domain host to get it all sorted. You can't finish the installation unless the Let's Encrypt portion of the install finishes without any errors. 

That also means you need to have bought your domain and figured out a way to point that domain to ports 80 and 443 of your Raspberry Pi on your local network, before you get to the Let's Encrypt portion of the tutorial. 

Originally, I used the Firewalla Gold Plus I have installed on my home network and its built-in dynamic DNS feature to point my domain to my home's IP address. That way whenever Comcast decides to change my IP, the Firewalla DDNS address stays the same and the system manages routing all traffic to the new IP. I also opened the necessary ports, which isn't an ideal security scenario -- as you can see from the screenshot of someone attempting to access my Pi almost immediately after setting it up. Thankfully Firewalla blocked it. 

A couple days after I first set up my server, I decided to make the switch to Cloudflare Tunnels. This allowed me to close the open ports and allow Cloudflare to handle routing traffic to my home's IP address. I don't have a guide I followed for this -- I literally had a Zoom call with a friend of mine who is well-versed in networking and Cloudflare. I shared my screen and he walked me through which buttons to press and what information to enter in each field. 

The best part? It's entirely free. 

A backup solution... for now

I need to find a good way to automatically back up my Pi, probably once a week. I have aSynology NAS and so I searched for and found a couple of guides to walk me through creating a scheduled backup. Originally, I gave this guide a try since it creates an image I can just write to a new microSD card. It works, but the image size is basically the same as your microSD card, even when you're not using all that space. 

I ran that backup task for a couple of days, and then I switched to RasPiBackup. The backups it creates are smaller, saving me space on my NAS, but the app requires all of the Pi's services and apps to be closed during the backup. That means my Pi, and thus my Mastodon instance, is taken offline for upwards of 90 minutes when a backup is created. It's not a huge deal if I run it in the middle of the night, but it's not ideal. 

At first, I was making nightly backups, but I've since switched to weekly backups. If I can figure out a different backup solution that runs in the background and only backs up any and all data related to my Mastodon instance, I'll switch to that. 

What's left to figure out

I've been monitoring how much storage space the instance is going to take up. Remember, I have a limited amount of storage. It's not a small amount, as I used a 256GB microSD card, but it's something I need to be aware of. Thankfully, Mastodon admins can set media retention policies in their account dashboard. Currently, I have it set to indefinitely as I watch how much space is being used. After three weeks, there's roughly 12.2 GB of media being stored on my Pi. I may end up setting a 90-day media retention policy. But we'll see. 

If you're running your own Mastodon instance from home, especially on a Raspberry Pi, what have you done to secure your server, if anything? What about backing it up?

Free free to follow me on Mastodon. You will need to sign up on a server and then you can copy and paste this link into the search bar in order to find my account: https://mrcippy.xyz/@mrcippy. If you do follow me, don't be shy. Say hi! 

Innovation

I tried Apple Vision Pro and it's far ahead of where I expectedThis tiny satellite communicator is packed full of features and peace of mindHow to use ChatGPT: Everything you need to knowThese are my 5 favorite AI tools for work
  • I tried Apple Vision Pro and it's far ahead of where I expected
  • This tiny satellite communicator is packed full of features and peace of mind
  • How to use ChatGPT: Everything you need to know
  • These are my 5 favorite AI tools for work

tag-icon Hot Tags : Social Media

Copyright © 2014-2024 Hi-Network.com | HAILIAN TECHNOLOGY CO., LIMITED | All Rights Reserved.