Hello!
With the recent news about Discord, I’ve seen several people starting to consider Matrix as an alternative. That’s why I wanted to share my experience with self-hosting it, because the whole hosting and upkeep of the server can be extremely simplified (and kind of cheap), if you choose the right tools for the job.
tl;dr - You can host Matrix with 2 very simple config changes and around 4 commands through this ansible project.
A little disclaimer - my use-case for Matrix is mostly to just bridge other messanging platforms, in my case it’s Discord (text only), WhatsApp, FB Messenger and Telegram. I have set up voice support but never properly stress-tested it, and the user count of my server is 2 users. While the setup process will mostly be the same, I can’t vouch for the chosen VM to handle higher traffic.
The main project I wanted to talk about is the matrix-docker-ansible-deploy, because it makes self-host the whole Matrix stack, along with a metric ton of optional services, extremely easy. For those that don’t know, ansible is a tool that allows you to write “playbooks” of steps to run on a specified server that will set up whatever you need. In this case, the playbook is set up to install Matrix and any of the dozens of services, install it and their requirements, configure it, and all you have to do is set up config options telling it what you want and run the playbook, making it super easy.
So, how does the self-hosting actually looks like? I’m assuming knowledge about setting up hosting, ssh, domain, and basic work with docker.
You need to get a domain, and get a VPS. I’ve chosen Hetzner cloud CAX11 (ARM, 2 VCPU, 4GB RAM, 40Gb storage), which goes for ~7$ a month including storage and IP.
Get your private key and IP, and don’t forget to set up firewall. You also need to set up Ansible and Just on your computer, here’s the docker I’m using for the job. Make sure to run it from the matrix-docker-ansible-deploy folder (so from inside the repo):
docker run -it --rm -w /work -v `pwd`:/work -v $HOME/Work/Matrix-server/hetzner.key:/root/.ssh/id_rsa:ro --entrypoint=/bin/sh docker.io/devture/ansible:2.16.1-r0-0
Once you’re there, you just pull the ansible project and can start with a Quickstart. This is the most difficult step - you have to set up and configure two files, one with your server host IP, and one with config vars.yml.
But, the basic config is extremely simple. You just give it a domain, and generate a few DB passwords, and you’ll have a working matrix server. If you want other services, like bridges, it’s usually also simple, and the documentation is clear. For example, adding voice support was literally just adding matrix_rcp_enabled: true into the vars.yml file.
Once you have that set up, the whole install process is literally running (from inside the ansible docker mentioned above)
just update (to update the playbook)
and then
ansible-playbook -i inventory/hosts setup.yml --tags=install-all,ensure-matrix-users-created,start
And that’s it. Assuming you have your server SSH key set up properly, it should simply run and install whatever you have configured. It might throw some errors, but so far every one I’ve seen was extremely clear.
Also, don’t forget to update often! I’m using this command from the ansible docker (with ssh key setup) mentioned above that does it:
git config --global --add safe.directory /work && git pull && just roles && just setup-all
I’ve never had the ansible fail in a way I couldn’t figure out, even when I was updating after more than half a year - the script is so robust it even told me to remove depreciated config options. It’s one of those rare projects that is so extremely robust it can handle a lot of situations. The only difficult issue I had in the two years was running out of space, since that made random things fail, and Matrix is pretty data heavy (because it saves all images).
As for my experience with matrix, I’ve been using it as my only message app for two years, and most of the time, it has been fine.
There are a few caveats:
- WhatsApp bridge requires me to log in to WhatsApp app every two weeks. I just have it in a separate quarantine profile on my GrapheneOS, and log it from time to time.
- Messenger bridge has stopped logging in after two years of usage without issues last week. I haven’t solved it yet, but it looks like Meta has upped their bot detection.
- Discord bridge works great for chat, including servers, but AFAIK you can’t join voice.
- Telegram had issues with logging out when I used a new account, but after using my personal, it’s all right. Topics don’t work AFAIK, though.
- And of course - all of the apps still get my data and my messages.
But, I was tired of not being able to convince my friends to switch, and by bridging it all to Matrix, I can at least avoid having their apps and visiting their sites, which is an OK compromise for me.
If you have any questions, feel free to ask. I wanted to share some visibility for this project, because just by watching the gazzilion of steps the playbook is doing, I can imagine that trying to actually self-host Matrix manually might be pretty long edeavour, but this project has so far done everything perfectly in a matter of three commands and a config change.
Good to hear that it’s easier to self host.
There are still some major issues on the client side
- no multi account on Element X
- no official threads support on Element X (it’s currently an experimental feature)
- the latest version of the call features can’t be used from Element Classic or Fluffychat (https://github.com/krille-chan/fluffychat/issues/2329)
Element always seems in a state of permanent rewrite from the Riot.im days to now.
deleted by creator


