Why your own Matrix server?
Matrix is an open, decentralised protocol for chat, voice and video calls – comparable to email: every server belongs to someone else, yet everyone can talk to each other. With your own server based on Synapse, you decide where messages and files are stored, who may register and how long data is kept. That's interesting for clubs, gaming communities, teams and companies that care about data sovereignty.
As a client, your members use Element, for example – in the browser, on the desktop or as an app for iOS and Android.
What you need
- A KVM server: with Debian or Ubuntu and Docker. For a community of up to about 100 active users, 2 vCores and 4 GB RAM are enough; joining large public rooms on other servers needs considerably more RAM and storage.
- A domain: for example your-domain.com for user names (@name:your-domain.com) and matrix.your-domain.com for the server itself.
- A reverse proxy with HTTPS: such as Nginx with Let's Encrypt.
Step 1: Generate the configuration
Install Docker (guide: Docker Engine on Debian 12) and let Synapse generate a base configuration. The server name can't be changed later – use the domain that should appear in user names:
mkdir -p /opt/matrix && cd /opt/matrix
docker run -it --rm -v "$(pwd)/data:/data" \
-e SYNAPSE_SERVER_NAME=your-domain.com \
-e SYNAPSE_REPORT_STATS=no \
matrixdotorg/synapse:latest generateThe data folder then contains homeserver.yaml and your server's signing key.
Step 2: Start Synapse with PostgreSQL
SQLite is only good for trying things out. For long-term use, Synapse uses PostgreSQL – the collation C when creating the database is important:
# /opt/matrix/docker-compose.yml
services:
synapse:
image: matrixdotorg/synapse:latest
restart: unless-stopped
volumes:
- ./data:/data
ports:
- "127.0.0.1:8008:8008"
depends_on: [db]
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: synapse
POSTGRES_PASSWORD: A-LONG-PASSWORD
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
volumes:
- ./postgres:/var/lib/postgresql/data# data/homeserver.yaml – replace the database section
database:
name: psycopg2
args:
user: synapse
password: A-LONG-PASSWORD
dbname: synapse
host: db
cp_min: 5
cp_max: 10Start both with docker compose up -d and check the logs with docker compose logs -f synapse.
Step 3: Reverse proxy and delegation
Synapse only listens locally on port 8008. Nginx forwards the Matrix paths; two small JSON responses on the main domain make sure other servers and clients find your Matrix server ("delegation"):
# matrix.your-domain.com
location ~ ^(/_matrix|/_synapse/client) {
proxy_pass http://127.0.0.1:8008;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
client_max_body_size 50M;
}
# your-domain.com – delegation so users are called @name:your-domain.com
location /.well-known/matrix/server {
default_type application/json;
return 200 '{"m.server": "matrix.your-domain.com:443"}';
}
location /.well-known/matrix/client {
default_type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '{"m.homeserver": {"base_url": "https://matrix.your-domain.com"}}';
}Get certificates for both domains with Certbot. The Federation Tester at federationtester.matrix.org shows whether federation works.
Step 4: Create users and secure the server
Open registration is disabled in Synapse by default – good. Create your first admin account on the command line:
docker compose exec synapse register_new_matrix_user -c /data/homeserver.yaml -a http://localhost:8008- Registration: Create further accounts the same way or hand out registration tokens instead of opening registration to everyone.
- Backups: Regularly back up a PostgreSQL dump, the media_store folder and the signing key in data – without the key your server can't restore its identity.
- Updates:
docker compose pull && docker compose up -dkeeps Synapse current; read the upgrade notes in the Synapse documentation first.
Frequently asked questions
Matrix or Discord for my community?
Discord is convenient, but all data lives with Discord. Matrix gives you full control and is open to other servers – in return you run it yourself. Many communities use both: Discord for reach, Matrix for internal teams.
How much RAM does Synapse need?
For small communities, 2–4 GB for Synapse and PostgreSQL are enough. Large federated rooms increase requirements considerably – then plan 8 GB or more.
Are there alternatives to Synapse?
Yes, for example leaner homeserver implementations. Synapse is the reference implementation with the widest adoption and the most detailed documentation – the safest choice to start with.
Which server fits?
A KVM server with 2 vCores and 4 GB RAM is a good start. In the KVM configurator you put together cores, RAM and storage freely and upgrade later.
Was this post helpful?
MagicHosting – Hosting with real value
Hosting pays off with MagicHosting: fair pricing, current deals and operation in SkyLink RZ. Servers, domains and personal support – no hidden costs.
- Current limited offers from our server exchange
- Affordable domains with transparent pricing and great offers
- Powerful DDoS protection for maximum availability
- Personal support when you have questions or issues