Matrix is an open, decentralized communication protocol, and Synapse is its most widely-used server implementation — letting you run your own chat (and voice/video) server that can optionally federate with other Matrix servers.
What Makes Matrix Different
Unlike a single-vendor chat platform, Matrix is a protocol — your self-hosted server can communicate with users on other Matrix servers (federation), similar in spirit to how email works across different providers, while remaining fully functional standalone if you disable federation.
Prerequisites
- Ubuntu 22.04/24.04 VPS: 2 vCPU, 4 GB RAM minimum
- PostgreSQL (recommended over the default SQLite for production use)
- A domain name
Step 1 — Install Synapse
sudo apt install matrix-synapse-py3 -y
The installer prompts for your server's domain name during setup — this becomes part of every user's Matrix ID (e.g. @user:yourdomain.com).
Step 2 — Configure PostgreSQL as the Database
sudo -u postgres createuser synapse_user -P
sudo -u postgres createdb -O synapse_user synapse -T template0 --locale=C --encoding=UTF8
sudo nano /etc/matrix-synapse/homeserver.yaml
database:
name: psycopg2
args:
user: synapse_user
password: CHANGE_ME_STRONG_PASSWORD
database: synapse
host: localhost
Step 3 — Start Synapse
sudo systemctl enable --now matrix-synapse
Step 4 — Configure Nginx as a Reverse Proxy
server {
listen 443 ssl;
server_name matrix.yourdomain.com;
location /_matrix {
proxy_pass http://127.0.0.1:8008;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
Step 5 — Add HTTPS
sudo certbot --nginx -d matrix.yourdomain.com
Step 6 — Create Your First User
register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml http://localhost:8008
Step 7 — Connect a Matrix Client
Use any Matrix-compatible client (several official and third-party apps exist for desktop, mobile, and web), pointing it at your server's domain and signing in with your created account.
Disabling Open Registration (Recommended)
enable_registration: false
Prevents strangers from creating accounts on your server if you don't intend it to be publicly open — use the register_new_matrix_user command shown above for controlled account creation instead.
Enabling Voice/Video Calls
Matrix supports voice and video calling between users natively through compatible clients — for larger group calls, integrating a dedicated SFU (Selective Forwarding Unit) component is recommended; consult current Matrix/Synapse documentation for this more advanced setup.
Federation Considerations
Decide deliberately whether to enable federation (communicating with other Matrix servers) — disable it entirely for a fully private, internal-only deployment, or enable it if you want your users to communicate with people on other Matrix servers/networks.
Common Errors
Client can't connect to the server — verify the reverse proxy correctly forwards /_matrix paths, and that DNS/well-known delegation is correctly configured if using a subdomain different from your base domain.
Continue Reading
- How to Install a Self-Hosted Video Conferencing Server (Jitsi Meet)
- VPS Requirements for VoIP and Communication Servers
- How to Install and Secure MySQL 8 on Ubuntu & Debian
Browse more articles in VoIP & Communication Servers.