Running Synapse in Docker for production: what changes after the test container
A test container proves that Synapse starts. A production service needs four things the test container usually lacks: a permanent server_name that will never change, signing keys and media that survive container replacement, PostgreSQL in place of SQLite, and a reverse proxy in front of the listeners. Each of these is hard to change later, so decide them before the first real user registers. The server_name in particular becomes part of every user ID and room ID, so a value chosen for a laptop demo can become a permanent liability.
The Synapse documentation recommends PostgreSQL for production and supports SQLite mainly for small or test installs. Current releases also set floors: Synapse 1.143.0 and later require PostgreSQL 14 or newer, and 1.142.0 and later require Python 3.10 or newer. Check the version you plan to run against the Synapse upgrade notes before you pick a PostgreSQL image tag, because the floors move with releases. Confirm that your chosen PostgreSQL major version is still within its support window, since Synapse drops versions once they reach upstream end of life.
The Docker image is one of several install routes. Packages, the Element Server Suite Helm chart and other methods each change where configuration, keys and data live, so the container-specific steps here assume you keep the data directory and database on storage you manage. Treat the image tag as a pinned input, not a floating latest, and read the upgrade notes for every release in between before you move it. Ask your platform team which registry, backup tooling and volume driver they already support, since those choices shape the rest of the build.
Which Docker layout fits your environment
A single host running Docker Compose is the simplest layout. Synapse and PostgreSQL run as separate containers on one machine, usually with a shared Compose file, a bind-mounted data directory for Synapse and a named or bind-mounted volume for PostgreSQL. Everything fails together, so the recovery plan depends on backups that leave the host. Upgrades are manual image pulls followed by a restart, which makes reading the upgrade notes for each release your job.
- Backups: you must schedule PostgreSQL dumps or base backups and copy the Synapse media store and signing key off the host.
- Upgrades: you pin image tags, take a database backup, then pull and restart. Synapse's upgrade notes warn that rolling back can be difficult because of schema changes.
- Database ownership: the database is your responsibility, and so is its patching and version floor.
- Failure domain: a host outage stops federation and client traffic until the host or a restored copy returns.
- Fit: suits small or pilot services with a clear owner who can restore the host quickly.
Before choosing this layout, confirm your restore time objective with your business owners and test a restore of both the database and the media store on a second machine.
In this layout, Synapse runs as a container scheduled by an orchestrator you already operate, such as Kubernetes, with persistent volumes for the media store and configuration. The orchestrator handles restarts, rollouts and health checks, but it does not manage Synapse's data for you. You still own the signing keys, the configuration secrets and the media volume. Teams with an existing platform often choose this path to reuse their ingress, monitoring and secrets tooling.
- Persistent storage: confirm the storage class supports the access mode Synapse needs for its media and config paths, and that volumes survive node replacement.
- Secrets: signing keys and database passwords should come from your secrets store, not from image layers or plain manifests.
- Upgrades: rolling image updates require a database backup and a check of the release notes first, because the orchestrator will not stop a schema change from going out.
- Scaling: adding replicas of the main process is not a simple scale-out. Worker processes and Redis are a separate design topic.
- Database placement: the database can still run in the cluster, but its storage and backup are a separate concern from Synapse.
Confirm with your platform team which team is paged for a failed rollout and whether your cluster's backup tooling can capture the media volume.
In this layout, PostgreSQL runs on its own hardware, a managed service in your cloud accounts or under a database operator, and Synapse containers connect to it over the network. The PostgreSQL documentation supports hot standby servers, synchronous and asynchronous replication, and point-in-time recovery through continuous archiving, but it states that automatic failover needs external tools. This separation lets a database team own backups, minor patches and major upgrades under its own change process.
- Major upgrades: the PostgreSQL docs describe dump and restore, pg_upgrade, and logical replication. Synapse also requires PostgreSQL 14 or newer for recent releases, so check the version floor first.
- Minor updates: these replace executables and restart without changing the storage format, so they need a restart window but not a data migration.
- Failover: you must choose and test an external tool if you want automatic promotion.
- Connections: size the connection limits with the database team and consider a pooler such as PgBouncer.
- Locale and encoding: confirm with the database owner that the database is created with the settings Synapse's setup guide requires.
Ask the database owner to show the last tested restore and the named person who approves a major version change.
How to generate config and signing keys for Synapse in Docker
This sequence produces a Synapse configuration file bound to your intended server_name, a signing key stored on a persistent volume, and a running listener that answers requests before any database or proxy work begins.
Create persistent host directories for Synapse
Before starting any container, create a host directory for Synapse data and mount it into the container at the data path the image uses. Keep the configuration and signing key on this volume rather than inside the container filesystem, so a container replacement does not create a new identity. Confirm the directory exists, is owned by the user the container runs as, and is included in your backup scope. The check is a directory listing that shows the mount target is writable by that user.
Run the image in generate mode
Run the official Synapse image once in its generate mode, passing the server name and the data directory. This writes a starter homeserver.yaml and creates the signing key. Use the exact image tag you intend to run in production, pinned to a specific version rather than a floating tag, so the generated config matches the software that will read it. Confirm the command exits without error and that homeserver.yaml now exists in the mounted directory.
Set server_name and check it before first start
Open the generated homeserver.yaml and confirm the server_name value is the permanent domain you intend users to appear under, such as the part after the colon in a user ID. Treat this value as fixed: changing it after users and rooms exist changes how they are identified. Also confirm the report_stats setting reflects your policy and that the data directory and signing key path match the mounted volume. The check is reading the file and matching each value against your naming plan.
Confirm the signing key file exists
Locate the signing key file in the persistent data directory, named after the server name in the generated configuration. Confirm it is present, non-empty, and readable only by the service user, with restrictive file permissions. Record where it is stored and include it in your secure backup, because losing it breaks federation identity for the server. The check is a file listing showing the key file with the expected name and owner, plus a note that it is in the backup set.
Adjust listener settings for the container
In the configuration, set the main HTTP listener to bind on a port inside the container that your reverse proxy can reach, and disable TLS on that listener because the proxy will terminate TLS. Set the listener to accept forwarded headers only from the proxy network. Leave federation and admin resources off any public path. Check the listener block in the file against your proxy plan before starting the service.
Start the container and confirm the listener answers
Start the Synapse container with the same volume mounts and config path, then review the startup logs for configuration errors and any message about a missing database, since PostgreSQL is added in a later step. From a shell on the Docker host or inside the container network, request the client versions endpoint on the listener port. A JSON response confirms the process is serving. Record the response and the container image tag for your change log.
Confirm the config still matches the intended server name
After the first successful start, reread the active configuration and the server name the process reports, then compare them with your naming record. Make sure no second signing key was generated and the original key file is unchanged in content and timestamp. This check guards against a restart that pointed Synapse at an empty or different volume. Only proceed to the database and proxy steps when the server name, key file and listener match the plan.
Only the proxy should reach Synapse, and Synapse should reach only its database
The diagram starts with clients and federating servers arriving at the reverse proxy on public ingress. The proxy forwards client and federation paths to the Synapse listener inside the internal Docker network, and Synapse connects to the PostgreSQL container over that same private network. Synapse reads its config and signing keys from mounted volumes, and writes media to a persistent volume. Check that the federation listener on port 8448 is firewalled, that the admin API paths are not routed publicly, and that PostgreSQL has no published port.
Request path from public ingress through the proxy to Synapse and PostgreSQL, with trust boundaries.
Listener, database and storage settings and when each fits
This table compares the Synapse listener, database, media store and federation whitelist settings, showing when each fits a production Docker deployment and what breaks when it is set wrong. Read each row as a decision: the setting, the case where it fits, and the failure to check for before go-live.
| Setting | When it fits | What breaks if it is wrong |
|---|---|---|
| listeners: bind_addresses and port | Bind to 0.0.0.0 inside the container so the proxy can reach the listener, and publish only the port the proxy forwards. | Binding to 127.0.0.1 inside the container makes the listener unreachable from the proxy container, so clients see gateway errors. |
| listeners: x_forwarded | Set to true when a reverse proxy terminates TLS and forwards client addresses, so Synapse logs and rate limits see real client IPs. | If left false behind a proxy, every request appears to come from the proxy address, so rate limits and audit logs lose per-client detail. |
| listeners: resources (client, federation) | Keep client and federation resources on the main listener on port 8008 and 8448 with the names your proxy routes expect. | Missing or mismatched resource names mean client or federation paths return errors, and remote servers cannot reach the homeserver. |
| database: PostgreSQL | Use PostgreSQL for any production or multi-user service, since Synapse documents it as the production choice. | SQLite suits small test installs but cannot support a production workload well, and migrating databases later adds a project of its own. |
| database: PostgreSQL version | Use a PostgreSQL major version that Synapse currently supports, confirmed in the Synapse upgrade notes before install. | Synapse 1.143.0 and later require PostgreSQL 14 or newer, so an older database blocks upgrades to those releases. |
| media_store_path | Point to a persistent volume outside the container filesystem so uploaded media survives container replacement. | If the path is inside the container layer, media disappears when the container is recreated, and users see broken images and files. |
| federation_domain_whitelist | Set to a list of approved domains for a closed or partner-only deployment, and set to an empty list to disable federation entirely. | An unset or overly broad list exposes the server to federation with unknown domains, while an empty list cuts off remote users you may need. |
Which data must survive a container restart
A Synapse container is disposable, but the state behind it is not. The signing keys, configuration, media, database and image version together decide whether the homeserver comes back with the same identity and data after a restart, a host loss or an upgrade.
Signing keys
The server signing key identifies your homeserver to other servers in federation. It is generated on first start and stored in the data directory. If it is lost or replaced silently, peers see a different server identity and federation trust breaks. Back up the key file with the rest of the data volume, restrict its permissions, and confirm the path is on a persistent volume before the first real user signs in.
Synapse docsHomeserver configuration
The homeserver.yaml file holds server_name, the database settings, listener definitions and secrets such as registration and macaroon keys. Changing server_name after users exist effectively creates a different server, so it must be fixed before launch. Keep the file in version control or a secrets store, mount it read-only into the container, and record each change alongside the image tag it was tested with.
Media repository
Uploaded files and cached remote media live in the media store directory, usually a separate persistent volume. Losing it breaks old messages that reference uploads, while growth can fill the disk and stall the server. Size the volume for growth, back it up on the same schedule as the database, and check that the media path in the container matches the volume mount.
PostgreSQL data
The PostgreSQL volume holds every room event, account and device record, so it is the most costly state to lose. Run it in its own container or host with its own volume, take regular logical or physical backups, and test restores into a scratch environment. Keep backups and the Synapse media store consistent with each other, since a database restored without matching media produces broken references.
Docker image tag
The image tag pins the exact Synapse build your database schema was migrated by. Use a specific version tag rather than latest, and take a database backup before each upgrade. The upgrade notes warn that rolling back can be difficult because of database schema changes between releases, so the practical rollback is restoring the pre-upgrade database backup with the older image, not running the older image against the new schema.
Questions teams ask before running Synapse in Docker in production
How much effort does a production Synapse Docker setup take?
Effort depends mostly on how many services sit around Synapse and how much of the setup you own. A production setup includes the Synapse container, a PostgreSQL database in its own container or on a separate host, persistent volumes for media and signing keys, a reverse proxy, DNS and certificates, and an email path for password resets. Each piece adds configuration and testing work, and the listener settings must match the proxy in front of it. The Synapse upgrade notes add recurring work, because each release can change the database schema and rolling back can be difficult. Ask any partner to price the setup as a written scope that lists each component, the environments involved and the upgrade process you expect to run.
Can an internal team run Synapse in Docker without outside help?
An internal team can run it if it already operates containers, PostgreSQL, TLS certificates and a reverse proxy, and if someone reads every Synapse upgrade note before each release. The skills gap usually sits in federation and delegation, database maintenance and the upgrade path, not in starting a container. Check whether the team has a named owner for the homeserver, a tested backup and restore routine, and time to follow platform floors such as the PostgreSQL and Python versions that Synapse requires. A partner can cover the first build and handover while your team keeps day-to-day operation.
What does the work need from our DNS, certificates, proxy and database host?
The work needs four things from your infrastructure. DNS must point the Synapse host name at a server you control, and your server name plan must be settled before the first run because it becomes part of every user ID. Certificates must cover the public host name, and the federation listener on port 8448 needs a route that other servers can reach or a deliberate decision to disable federation. A reverse proxy must forward the client and federation paths with the headers Synapse expects. A PostgreSQL host, container or managed service must be reachable from the Synapse container with a database created with the correct locale. Confirm each item with your network and security teams before work starts.
How long do the first run and test take?
The duration depends on your change process, how many environments you need, how many people test and how many integrations you connect at launch. A first run usually includes config generation, a smoke test of login and room creation, a federation test against a second server or a federation tester, media upload checks, email verification and a restore test from backup. Each step can be short on its own, but approvals, certificate issuance and DNS propagation often set the pace. Ask a partner for a timeline in the written scope that separates build, test, security review and go-live, and identify which of those steps your organization must approve.
Does Synapse have to run on PostgreSQL?
Synapse documentation recommends PostgreSQL for production, and SQLite is also supported. For a production service, PostgreSQL is the expected choice because it handles concurrent load and backups better. Current Synapse releases set a floor on the database version: Synapse 1.143.0 and later require PostgreSQL 14 or newer. PostgreSQL 14 is listed as supported until November 12, 2026, so plan a PostgreSQL version that stays in support for the life of your Synapse release. Confirm the Synapse version you plan to deploy and its database requirement in the upgrade notes before you choose the database image.
What happens to users if the server name changes?
Users and rooms are identified by the server name, so changing it creates new identities for everything on the server. A user on @alice:example.com does not become a user on a new name, and rooms created under the old name keep their original identifiers. The server name is fixed in the configuration when the homeserver is first created, and changing it later is not a simple configuration edit. Treat the server name as a permanent decision, choose it before users register, and use delegation so the service host can change while user IDs stay the same. Confirm the plan with the owners of your domain before any user data exists.
Is the Docker setup enough for federation and external access?
Running the container does not by itself make the server reachable to other homeservers. Federation needs a public route to port 8448 or delegation to a host that serves it, a correct certificate chain and DNS records that match your server name. If you do not want federation, Synapse can restrict it through the federation domain whitelist, and the documentation recommends also firewalling the federation listener. Decide which policy you want before launch, because it changes what your proxy, firewall and monitoring must handle. Test the chosen setup with a federation checker and confirm the policy with your security team.
What should we ask a partner to include in a quote?
Ask for a written scope that lists each component, who builds it, who operates it afterward and what the handover contains. The quote should state the server name plan, the deployment target, the database setup and version, the proxy configuration, backup and restore tests, the upgrade process and the federation policy. Ask which items are one-time, such as the initial build and security review, and which recur, such as upgrades and monitoring retainers. DeployOpen works from written, fixed-scope agreements, and a quote follows from that scope, so the more precisely you define the environments and components, the more comparable the quotes will be.
Security and operational risks of a containerized Synapse
A containerized Synapse is easy to start and easy to expose by accident. The cards below cover the settings, network paths and data handling choices that most often turn a working test container into a weak production service, and what to check for each one before users arrive.
Admin API and replication exposure
The /_synapse/admin API and the replication listener are powerful internal surfaces, and neither should be reachable from the internet. Your reverse proxy should forward only the client, federation and well-known paths it needs, and return an error for admin paths from outside your management network. Confirm this from an external host, not from inside the Docker network, because a container-to-container test will always pass.
Configuration manualFederation listener firewalling
Federation runs on port 8448 by default, and an open federation listener lets any server on the internet send requests to your homeserver. Synapse's federation_domain_whitelist restricts which domains may federate, and an empty list disables federation entirely. The docs also recommend firewalling the federation listener itself, so check that the port is published only where you intend it, and that the whitelist matches your federation policy.
Federation docsPostgreSQL authentication methods
The Synapse database account should authenticate with SCRAM rather than MD5. PostgreSQL 18 deprecates MD5 password authentication in favor of SCRAM, so a database password set up with older defaults should be rotated and the pg_hba.conf entry for the Synapse network should name scram-sha-256. Restrict the allowed source to the Synapse container network, and review the client authentication methods PostgreSQL documents before choosing one for a database container.
Secrets in environment variables versus files
Values passed as environment variables appear in docker inspect output, process listings and many logs, and they are copied into any compose file that lists them. Keep the signing key, database password and registration secrets in files with restricted permissions, mounted into the container, and reference those paths from configuration. Ask who on your team can read the host volume and whether backups of that volume are encrypted.
Unpinned image tags
A tag such as latest can change between two pulls, and Synapse upgrade notes warn that some releases change the database schema in ways that are hard to reverse. Pin the image to a specific release, record the digest in your change record, and read the upgrade notes for every version between your current pin and the target before you move it. Test the upgrade against a restored copy of production data first.
Stale data after a restore
Restoring the PostgreSQL database without the matching media files, signing keys or configuration leaves Synapse pointing at data that no longer exists, and restoring an older database over newer media can break references. Back up the database, the media volume and the signing key together, and test a restore on a separate host. Confirm the database schema matches the Synapse release you run, because rolling back across schema changes can be difficult.
How upgrades change the Docker production setup
Once Synapse runs in Docker for production, upgrades become part of the container routine rather than a one-off event. Pin the image to an explicit version tag in your Compose file or orchestrator manifest, never latest, so that a pull cannot change the running homeserver without a reviewed decision. Before changing that tag, read the upgrade notes for every release between your current version and the target, not only the newest one, because some releases change database schema or required settings. Then take a database backup of PostgreSQL in its own container and keep the homeserver.yaml and signing key files from the data volume, so you have a restore point before the new image starts.
Platform floors matter as much as the Synapse version. Synapse drops support for Python and PostgreSQL versions once they reach upstream end of life, and newer Synapse releases can require a newer PostgreSQL than your current database container provides. Check the required PostgreSQL and Python versions in the notes for your target release, and plan a PostgreSQL upgrade as its own change if the database image is behind. Confirm the supported PostgreSQL major versions on the PostgreSQL versioning policy page before you choose a database image tag.
Plan for rollback before you need it. The Synapse upgrade notes warn that rolling back can be difficult because schema changes between releases are not always reversible, so a restored database backup is usually the only safe way back. Record the exact image digests and tags you ran, test the upgrade on a copy of the database in a staging container, and confirm that your restore procedure works. The Matrix upgrades topic covers background database updates, rollback limits and version-by-version reading in detail.
How DeployOpen scopes, delivers and supports Synapse in Docker
DeployOpen plans and implements self-hosted open-source platforms inside the client's own infrastructure, including Synapse in Docker. For this topic, the work starts with a written scope covering the container layout, persistent storage, PostgreSQL, listener settings and the reverse proxy, so the team knows what it is getting before the build begins.
How we scope
- Confirm the Synapse version, the target container platform and the hosts or cloud accounts where the service will run.
- Agree the server name, the public hostnames and whether federation is enabled, limited or disabled.
- Record which PostgreSQL version your policy requires, and who owns the database, backups and upgrades after handover.
How we build
- Generate the configuration and signing keys, then store them on persistent volumes with documented ownership and permissions.
- Run PostgreSQL in its own container or on your database platform, and verify connectivity, locale and authentication settings.
- Configure listeners and proxy headers, then test client, federation and admin paths against the chosen design before go-live.
How we hand over
- Deliver the container definitions, configuration files, key inventory and runbooks for restart, upgrade and rollback.
- Document backup scope for the database, media and signing keys, with a restore test your team can repeat.
- Walk your operators through the upgrade notes process so each future Synapse release follows a checked procedure.
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer if your team wants DeployOpen to keep the service current.
- Plan periodic reviews of Synapse releases, PostgreSQL minor updates and proxy configuration as part of the retainer scope.
- Ask for the support boundaries, response expectations and change process in writing before the retainer starts.

