When you self-host a Matrix server with Synapse on a managed VPS, the accounts, rooms and message history of your conversations stay on a machine of your own, which our teams keep up to date and monitor day and night. Synapse is free software under the AGPL-3.0 license, written and maintained by Element. This guide follows its official documentation: the server name, installing with Docker and PostgreSQL, HTTPS and delegation, accounts, clients, calls, media, backups and updates.
By Simon Vasconcelos Lee
Published on 30 November 202615 minute read
@alice:example.com, and the documentation states that it cannot be changed later..well-known files to serve example.com from matrix.example.com, on port 443 alone.register_new_matrix_user. Add a TURN server for calls, then back up the database, the media and the signing key.Matrix is an open protocol for secure, interoperable real-time communication. Every organization can run its own server on it, called a homeserver: it keeps its users’ accounts, the rooms they join and their message history, and it talks to other Matrix servers through federation.
Synapse is an open source Matrix homeserver, written mainly in Python, developed and maintained by Element in the element-hq/synapse repository. Its users connect to it from a Matrix client, in the browser, on the desktop or on the phone.
Element also ships Synapse in its Element Server Suite distribution. This guide follows the standalone installation described in the Synapse documentation, with the official Docker image.
Synapse is dual-licensed by Element Creations Ltd. You can use it for free under the GNU Affero General Public License, version 3 or, at your option, any later version (AGPL-3.0-or-later), or under a paid Element commercial license, whose terms you agree with Element. Under the AGPL, you run Synapse for your company and your team with no license to buy.
Section 13 of the AGPL adds one condition: if you modify the program, your version must offer everyone who uses it remotely, over a network, a way to get its source code free of charge. For help, the README points to the community room #synapse:matrix.org and the admin FAQ, and offers professional support with service levels as part of an Element Server Suite subscription.
The Matrix name is a trademark of The Matrix.org Foundation, a not-for-profit organization that nurtures the Matrix ecosystem and the protocol specification, as the neutral custodian of a single standard. It welcomes as members the people and organizations who want to support it: its members page sets out the tiers. This guide uses the Matrix name to refer to the protocol, as its trademark policy provides.
This guide is independent of The Matrix.org Foundation and of Element: use of the Matrix name does not imply endorsement, sponsorship or affiliation.
The server_name setting gives the domain part of every ID: with example.com, your users are @alice:example.com and your rooms #welcome:example.com. It also tells other Matrix servers how to reach yours. The documentation is clear: this name cannot be changed later, so it is chosen before the first installation.
It advises using your domain, example.com, rather than a Matrix-specific subdomain such as matrix.example.com, for the same reason your email address reads you@example.com and not you@email.example.com. The name is written in lowercase.
| Setting | Example | What it carries |
|---|---|---|
server_name | example.com | The end of every ID and the address other servers look for; permanent |
public_baseurl | https://matrix.example.com/ | The address where clients actually reach Synapse, behind the reverse proxy |
Synapse can therefore run on matrix.example.com while keeping IDs in example.com: this is delegation, described below.
The official image is published on Docker Hub as matrixdotorg/synapse and at ghcr.io/element-hq/synapse. It runs Synapse as a single process and keeps everything in a /data volume: configuration, media and keys. The repository provides a Docker Compose example with PostgreSQL, which this file follows:
services:
synapse:
image: docker.io/matrixdotorg/synapse:latest
restart: unless-stopped
environment:
SYNAPSE_CONFIG_PATH: /data/homeserver.yaml
volumes:
- ./files:/data
depends_on:
- db
ports:
- 127.0.0.1:8008:8008
db:
image: docker.io/postgres:15-alpine
restart: unless-stopped
environment:
POSTGRES_USER: synapse
POSTGRES_PASSWORD: ${SYNAPSE_DB_PASSWORD}
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
volumes:
- ./schemas:/var/lib/postgresql/data
Put the database password in a .env file, next to compose.yaml:
SYNAPSE_DB_PASSWORD=a-long-unique-password
The image’s generate mode writes a starting homeserver.yaml, its logging configuration and the server’s signing key. It needs two variables: the server name, and whether or not to report anonymous usage statistics.
docker compose run --rm \
-e SYNAPSE_SERVER_NAME=example.com \
-e SYNAPSE_REPORT_STATS=no \
synapse generate
Then open files/homeserver.yaml. The generated listener serves port 8008, over HTTP, with x_forwarded: true to read visitors’ real addresses behind the proxy: keep it that way. The documentation asks you not to restrict bind_addresses to 127.0.0.1 in a container, or Synapse stops answering the proxy; publishing the port on 127.0.0.1, in compose.yaml, is what keeps it off the internet. Replace the database section, which points to SQLite, and add the public address:
public_baseurl: "https://matrix.example.com/"
database:
name: psycopg2
args:
user: synapse
password: "a-long-unique-password"
dbname: synapse
host: db
cp_min: 5
cp_max: 10
docker compose up -d
docker compose logs synapse
curl http://127.0.0.1:8008/health
Every Synapse HTTP listener exposes /health, which answers 200 OK while the server runs; the image also uses it for its own health check.
The documentation gives no server size. Its FAQ explains that Synapse keeps a lot of recent room data in memory to answer quickly, and that the SYNAPSE_CACHE_FACTOR variable, 0.5 by default, sets that balance. The size therefore depends on the number of accounts and on the large federated rooms your users join. On a managed VPS, tell us about your usage and we will recommend the right size.
By default, Synapse uses SQLite, which trades performance for convenience. The documentation asks almost all installations to use PostgreSQL: SQLite is only acceptable for testing there, and Synapse performs poorly with it, especially in large rooms.
C locale. That is the job of POSTGRES_INITDB_ARGS in the file above.shared_buffers, effective_cache_size, work_mem, maintenance_work_mem and autovacuum_work_mem.Make this choice from the start. If an instance already runs on SQLite, the synapse_port_db script moves it to PostgreSQL in two passes, a live copy and then a final pass with the service stopped. The documentation warns that after the move, the database may take 25% to 100% more space on disk.
Port 8008 is meant for local testing. For any real use, the documentation recommends an HTTPS reverse proxy in front of Synapse. It forwards the /_matrix and /_synapse/client paths to Synapse, sets the X-Forwarded-For and X-Forwarded-Proto headers, and must neither decode nor normalize the requested URI, which would break the signature checks of federation.
Clients arrive on port 443 by default, and other servers on port 8448. With the delegation in the next section, federation goes through port 443 too.
| Direction | Port | Protocol | Use |
|---|---|---|---|
| Inbound | 443 | TCP | Clients, and federation with delegation |
| Inbound | 8448 | TCP | Federation, without delegation |
| Outbound | 443 and 8448 | TCP | Federation to other servers, which use either one |
Caddy obtains and renews the HTTPS certificate on its own. This block follows the delegation example from the documentation: matrix.example.com carries Synapse, and example.com publishes the two .well-known files explained below.
example.com {
header /.well-known/matrix/* Content-Type application/json
header /.well-known/matrix/* Access-Control-Allow-Origin *
respond /.well-known/matrix/server `{"m.server": "matrix.example.com:443"}`
respond /.well-known/matrix/client `{"m.homeserver": {"base_url": "https://matrix.example.com"}}`
}
matrix.example.com {
reverse_proxy /_matrix/* localhost:8008
reverse_proxy /_synapse/client/* localhost:8008
}
This block follows the Nginx example from the documentation, reduced to port 80 so that Certbot can set up HTTPS. Add nothing after the port in proxy_pass, not even a slash: Nginx would then normalize the URI.
server {
listen 80;
listen [::]:80;
server_name matrix.example.com;
location ~ ^(/_matrix|/_synapse/client) {
proxy_pass http://localhost: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;
proxy_http_version 1.1;
}
}
sudo certbot --nginx
client_max_body_size follows max_upload_size, the largest upload Synapse accepts, 50 MB by default: Nginx only allows 1 MB without this setting.
Since version 1.165.0, the documentation sets the Host header without the port, as above: the $server_port that its earlier example added can cause a redirect loop during single sign-on (SSO). If your clients reach Synapse on a port other than the default one, use $http_host, which keeps that port, and add it to public_baseurl.
Neither example forwards /_synapse/admin. The documentation advises against exposing the admin API to the internet without good reason: call it from the server, on 127.0.0.1:8008.
Without further instructions, a server that wants to reach example.com connects to https://example.com:8448/. Delegation keeps IDs in example.com while sending that traffic elsewhere, for example to matrix.example.com on port 443. It takes one file served over HTTPS, on port 443, at the root of the domain:
{ "m.server": "matrix.example.com:443" }
With no port given, 8448 applies. A second file, optional but very useful, serves clients: with it, a user types their full ID, @alice:example.com, and their client finds the server address on its own. It must carry the Access-Control-Allow-Origin: * header for web clients.
{ "m.homeserver": { "base_url": "https://matrix.example.com" } }
example.com: these two files are published on that site’s server.308 redirects. If example.com redirects to www.example.com, serve the files directly, or switch the redirect to 301.public_baseurl uses the same address as base_url.serve_server_wellknown: true has Synapse serve the file itself, provided that https://example.com already reaches Synapse.To check, the matrix.org federation tester tells you whether your server is configured correctly for federation. Then join a room on another server, such as #synapse:matrix.org, the room for Synapse admins.
enable_registration is false by default: nobody can create an account from a client. You therefore create accounts from the command line, with the register_new_matrix_user script shipped in the image:
docker compose exec synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml
The script asks for the user name, the password and whether the user is an admin, then creates the account on the running server. Create your admin account first, then your team’s.
The script relies on registration_shared_secret, which generation wrote at random into homeserver.yaml. Anyone who knows it can register accounts, admins included, even with registration closed. Keep it secret, and remove it from the configuration, then restart, once you no longer need it.
enable_registration, the documentation strongly recommends at least one protection against bots: a captcha, a verified email address or phone number, or a registration token.registration_requires_token: true opens registration only to people who received a token, created with the admin API.federation_domain_whitelist limits it to a list of servers, and an empty list turns it off entirely.Synapse starts without email. With it, Synapse sends password resets, verification of addresses added to an account and, if you enable them, notifications of new messages. Without it, password reset, registration by email and email notifications stay disabled.
On a Simafri VPS, sending goes through an authenticated SMTP relay, on port 587: the address of a mail account you already have, or Simafri Suite.
email:
smtp_host: smtp.example.com
smtp_port: 587
smtp_user: "matrix@example.com"
smtp_pass: "the-account-password"
require_transport_security: true
notif_from: "Your %(app)s server <matrix@example.com>"
enable_notifs: true
require_transport_security requires STARTTLS: Synapse then refuses to send in plain text. notif_from is mandatory once sending is configured, and %(app)s takes the application name there, Matrix by default.
Your users install nothing on the server: they pick a Matrix client, then sign in with their full ID. The .well-known/matrix/client file saves them from knowing Synapse’s technical address. Without it, they enter https://matrix.example.com as a custom homeserver.
| Client | Platforms | What matrix.org says about it |
|---|---|---|
| Element Web and Desktop | Browser, Windows, macOS, Linux | Suited to new users and those coming from Slack or Teams |
| Element X | iOS, Android | The next generation of Element on mobile, with MatrixRTC calls |
| FluffyChat | iOS, Android, Linux, browser | Simple and approachable, especially on mobile |
The matrix.org clients page lists others, with the features of each. If you host Element Web yourself, the Synapse security page recommends serving it on a different registered domain from Synapse, or at least on a different subdomain, to limit the impact of a possible flaw in the user-supplied content Synapse serves.
For voice and video calls to work reliably between devices on different networks, the documentation requires a TURN server: it relays traffic when devices cannot reach each other directly. The Synapse Docker image does not include one, and the documentation asks for it to be hosted on a public IP address. It describes coturn and eturnal; with coturn, on the server:
sudo apt install coturn
use-auth-secret
static-auth-secret=a-long-random-secret
realm=example.com
no-tcp-relay
no-multicast-peers
denied-peer-ip=10.0.0.0-10.255.255.255
denied-peer-ip=172.16.0.0-172.31.255.255
denied-peer-ip=192.168.0.0-192.168.255.255
denied-peer-ip=127.0.0.0-127.255.255.255
user-quota=12
total-quota=1200
Synapse and coturn share this secret: Synapse derives temporary TURN credentials from it for each client. The denied-peer-ip lines stop the relay from reaching private addresses; the coturn page of the documentation gives the full list, to copy as is.
turn_uris:
- "turn:turn.example.com?transport=udp"
- "turn:turn.example.com?transport=tcp"
turn_shared_secret: "a-long-random-secret"
turn_user_lifetime: 1h
turns:.Element X calls rely on MatrixRTC. Synapse advertises a LiveKit server to clients through the matrix_rtc setting, with Element’s lk-jwt-service authorization service: one more component to install, alongside TURN. Since version 1.165.0, declare each LiveKit server in matrix_rtc with the m.livekit type, the stable transport, and keep a matching livekit entry, now deprecated, for as long as some clients still rely on it.
Synapse keeps a copy of the media your users upload, avatars and attachments, in its media store: with the Docker image, files/media_store. It also caches media from other servers that your users view. This folder grows with use, and so does the database.
| Setting | Default | Effect |
|---|---|---|
max_upload_size | 50 MB | The largest single upload; the reverse proxy must accept the same |
media_upload_limits | No limit | A maximum volume per user over a period, for example 100 MB per hour |
media_retention | Nothing is purged | Removes media not accessed for a given time, local and remote separately |
url_preview_enabled | Disabled | Link previews, which require a list of addresses the spider must not reach |
media_retention:
local_media_lifetime: 90d
remote_media_lifetime: 14d
Purging local media may remove the only copy of a file anywhere in the federation: keep a short lifetime for remote media, which Synapse can download again. The image README also shows how to put media on a separate, larger volume, with the other files on fast storage.
The documentation calls backups critical, against hardware failure as well as corruption from a bug or an admin mistake. Here is what it asks you to keep:
| Item | Where | Back up |
|---|---|---|
| Configuration | homeserver.yaml and example.com.log.config | Required, encrypted: it holds secrets |
| Signing key | example.com.signing.key | Required, encrypted: it signs events and federation requests |
| PostgreSQL database | The db service | Required, with pg_dump |
| Local media | media_store/local_content | Required: sometimes the only copy of these files |
| Local thumbnails | media_store/local_thumbnails | Recommended: no tool regenerates them with the default setting |
| Remote media and caches | remote_content, remote_thumbnails, url_cache | Optional: Synapse downloads them again |
A lost signing key can be replaced with a new one, which Synapse creates at startup. Then add the old public key to old_signing_keys: backing it up with the configuration remains simpler.
The documentation recommends pg_dump in custom format, which is more compact, without stopping PostgreSQL or Synapse: it takes a consistent snapshot. It asks you to exclude the data of the e2e_one_time_keys_json table, whose restore would reissue one-time keys already used, and cause decryption errors.
docker compose exec -T db pg_dump -U synapse -Fc \
--exclude-table-data e2e_one_time_keys_json synapse > synapse-$(date +%F).dump
The -T option disables the terminal, so that the file comes out intact and the command also runs in a scheduled task. Add a copy of the files folder, which holds the configuration, the key and the media, then send everything off site, encrypted.
Kept on the server’s disk, these Synapse-specific copies are also included in its nightly backups.
docker compose stop synapse.C locale: the documentation forbids restoring into a database that already has tables. On a fresh PostgreSQL volume, the official image creates the synapse database on its own, empty, with the POSTGRES_INITDB_ARGS options.pg_restore, then put the configuration, the signing key and the media back in place.e2e_one_time_keys_json table was backed up, empty it with TRUNCATE before starting Synapse again.docker compose exec -T db pg_restore -U synapse -d synapse < synapse-2026-11-20.dump
Synapse follows a two-week cycle: a release candidate, then the release, usually on a Tuesday. Bugfix and security releases come out in between when needed, and the Matrix blog sometimes announces a security release in advance. The latest stable version is 1.166.0, of 24 November 2026, and the upgrade notes list no special step for it. Version 1.165.0, of 10 November, requires Python 3.11 or later; with the official Docker image, which runs Python 3.13, no action is needed.
docker compose pull
docker compose up -d
curl http://127.0.0.1:8008/_synapse/admin/v1/server_version
At startup, Synapse runs its database migrations before serving, then carries on with background updates. After a long gap, the documentation advises going through each version that changes the schema, letting those updates finish before the next one. To pin a version, replace latest with its tag, such as v1.166.0.
Self-hosting means running the server on top of the application. On a managed VPS, our teams take charge of the server and proactively monitor your instance; Synapse remains your software, with its settings and its data.
| Topic | Our teams | You |
|---|---|---|
| The server | System and security updates, server interventions included | The timing that suits your business |
| Monitoring | Server monitored 24/7, with intervention without waiting for your call | Reading your instance’s logs |
| Synapse | Proactive monitoring: errors, slowdowns and disk space spotted, fix recommended | Its installation, updates and configuration, which you apply, yourself or through your AI assistant |
| Accounts and rooms | The server that carries them, monitored and backed up | Accounts, registration, federation and room moderation |
| Backups | Every night, encrypted and kept off the machine; restores included | Synapse’s own copies, and the restore request, when you need one |
| Migration | Your current server migrated, free of charge | The timing of the switch |
If you would rather have our teams work inside the application itself, that service is billed by the hour or at a fixed rate, with an estimate shared before the work starts.
With a Simafri Managed VPS, our teams keep the server that runs Synapse up to date, monitor it day and night and step in without waiting for your call; they also proactively monitor your instance and recommend useful fixes, which you apply, yourself or through your AI assistant. Backups are encrypted every night and kept off the machine, restores are included, and migrating your current server is free.
Yes. Synapse is dual-licensed: for free under the AGPL-3.0, version 3 or later, or under a paid commercial license from Element. Under the AGPL, you run it at work with no license to buy; if you modify it, your version must offer its source code to the people who use it over the network.
No. The Synapse documentation states that server_name cannot be changed later: it ends every ID, such as @alice:example.com. Choose it before you install, preferably your domain, and run Synapse on a subdomain through delegation.
Generate the configuration with the generate mode of the matrixdotorg/synapse image, setting SYNAPSE_SERVER_NAME and SYNAPSE_REPORT_STATS. Then connect PostgreSQL in homeserver.yaml, run docker compose up -d and put an HTTPS reverse proxy in front of port 8008.
No, if you use delegation. A /.well-known/matrix/server file on your domain tells other servers to go through matrix.example.com:443. Without delegation, servers look for your domain on port 8448.
Registration is closed by default. Run register_new_matrix_user in the container, with the homeserver.yaml file: the script asks for the user name, the password and the admin role. It relies on registration_shared_secret, which must stay secret.
It starts with SQLite, but the documentation keeps it for testing: SQLite should not be used in production, and Synapse performs poorly with it, especially in large rooms. Use PostgreSQL, with a database in UTF-8 and the C locale.
Yes. The Synapse documentation requires a TURN server for calls to work reliably between different networks. Install coturn on a public IP address, share its secret with Synapse through turn_shared_secret, and open ports 3478, 5349 and the relay range.
The configuration, the server signing key, the PostgreSQL database with pg_dump, excluding the data of the e2e_one_time_keys_json table, and the local media in the media_store folder. Remote media and caches are downloaded again.
A managed VPS covers the server: system, security, monitoring and backups. Our teams also proactively monitor your instance and recommend useful fixes, which you apply. Work inside the application is billed by the hour or at a fixed rate.
Simafri
Let's talk about your project
Tell us what you need in a few words: we will get back to you quickly.
Thank you! Your request has been sent. We'll get back to you shortly.
Prefer email? Write to us at support@simafri.com.