Matrix Synapse database config for PostgreSQL
The following config is for setting up the PostgreSQL database for Matrix Synapse in your homeserver.yaml
file:
database:
name: psycopg2
txn_limit: 10000
args:
user: synapse
password: eetah1vahnesh2be0eeshuP5thoopa
database: synapse
host: synapse_db
port: 5432
cp_min: 5
cp_max: 10
Remember to replace the password
with a secure one, and ensure that the synapse_db
service is correctly defined in your docker-compose.yml
.
The relevant docker-compose.yml
snippet for the PostgreSQL service might look like this:
services:
synapse_db:
image: docker.io/postgres:14-alpine
environment:
- POSTGRES_USER=synapse
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
volumes:
- ./synapse_db_data:/var/lib/postgresql/data
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U synapse"]
interval: 1s
start_period: 3s
timeout: 5s
retries: 60
See How to generate random PostgreSQL password in .env for docker-compose
for generating a random password for the PostgreSQL database in your .env
file.
Make sure to set the same password in both the docker-compose.yml
and the homeserver.yaml
file.
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow