No KYC · email optional · pay in Monero, Bitcoin or USDT
Language: English
Deploy a VPS

Guide · Self-hosting · checked 2026-11-10

How do I host a Matrix server on a VPS?

Matrix is an open chat protocol, and Synapse is its reference server. This guide installs Synapse from the project’s Debian packages and puts a reverse proxy in front of it.

Last updated: · 6 min read

Quick answer

How do I host a Matrix server on a VPS?

To host a Matrix server on a VPS, install Synapse from the Matrix.org apt repository, give it a PostgreSQL database, and put an HTTPS reverse proxy on port 443 in front of its port 8008. Gloamport’s Gloam plan, 2 vCPU, 4 GB RAM, 80 GB NVMe, 4 TB traffic at $8.25 a month on 12 months, is sized for it.

What does a Synapse install involve?

PartSettingWhy
Server nameThe domain in user IDs, for example example.com; cannot be changed laterFederation identity
Packagematrix-synapse-py3 from packages.matrix.orgDebian’s own package is not available for Debian 13 and older
Config overrides/etc/matrix-synapse/conf.d/Package upgrades do not ask to replace your config
Client and federation listenerHTTP on localhost:8008 behind a proxyThe proxy terminates HTTPS
DatabasePostgreSQL (psycopg2)The docs call SQLite acceptable for testing only
Ports443 for clients; 8448 for federation unless delegated to 443Both must be reachable from the internet
PlanGloam: 2 vCPU, 4 GB RAM, 80 GB NVMe, 4 TB trafficGloamport plan list

Prices checked on

What do you need before installing a Matrix server?

You need a domain name you control and a VPS with a public IPv4 address. The domain matters more than the server: the Synapse documentation says the server name is the domain part of every user ID, and that it cannot be changed later. Pick it before you install.

A Gloamport VPS comes with one IPv4 and an IPv6 /64 on every plan, so DNS records can point at it directly. A domain is not sold here; buy it where you prefer and create an A record for the host name you will use. Linux only: Debian, Ubuntu, AlmaLinux and Rocky Linux images. No Windows. Reserve about an hour for DNS and the certificate, besides the install itself.

How to install Synapse on Debian 13 or Ubuntu 24.04

The commands follow the official Synapse documentation. Run them as root or with sudo.

  1. Point DNS at the VPS

    Create an A record for matrix.example.com with the VPS address (and an AAAA record if you use IPv6). Wait until it resolves before asking for a certificate.

  2. Add the Matrix.org apt repository

    Download the signing key, add the repository line, and run apt update, as in the first code block. The documentation gives the key fingerprint AAF9AE843A7584B5A3E4CD2BCF45A512DE2DA058; compare it with gpg before you trust the key.

  3. Install matrix-synapse-py3

    Run apt install matrix-synapse-py3 and set the server name when asked. Change settings only through files in /etc/matrix-synapse/conf.d/.

  4. Create the PostgreSQL database

    Install PostgreSQL and the libpq5 library, then create the user and database with the commands in the second code block and point Synapse at it with the database block shown there.

  5. Put a reverse proxy in front

    Install a web server, get a certificate for the host name, and forward /_matrix and /_synapse/client to localhost:8008 as in the third code block. Set x_forwarded: true on the 8008 listener.

  6. Create your user and test

    Set a registration_shared_secret, restart Synapse, run register_new_matrix_user, then sign in from a Matrix client with your homeserver address.

1. Matrix.org repository and package
sudo apt install -y lsb-release wget apt-transport-https
sudo wget -O /usr/share/keyrings/matrix-org-archive-keyring.gpg https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" |
    sudo tee /etc/apt/sources.list.d/matrix-org.list
sudo apt update
sudo apt install matrix-synapse-py3
2. PostgreSQL: user, database and the Synapse database block
sudo apt install postgresql libpq5
sudo -u postgres createuser --pwprompt synapse_user
sudo -u postgres createdb --encoding=UTF8 --locale=C --template=template0 --owner=synapse_user synapse

# /etc/matrix-synapse/conf.d/database.yaml
database:
  name: psycopg2
  args:
    user: synapse_user
    password: CHANGE_ME
    dbname: synapse
    host: localhost
    cp_min: 5
    cp_max: 10
3. Reverse proxy and listener (nginx location from the Synapse docs)
# nginx: inside a server block that listens on 443 ssl for 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;
    client_max_body_size 50M;
}

# Synapse listener on port 8008, in homeserver.yaml or a conf.d file
listeners:
  - port: 8008
    type: http
    x_forwarded: true
    bind_addresses: ['127.0.0.1']
    resources:
      - names: [client, federation]
4. First user
# conf.d/registration.yaml  (a random value, kept secret)
registration_shared_secret: "RANDOM_VALUE"

sudo systemctl restart matrix-synapse
register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml

How much server does a Matrix homeserver need?

A private homeserver for a few people fits a mid-size plan, and federation to large public rooms is what grows the load. We have not benchmarked Synapse and give no user counts. Gloamport lists Gloam as the plan for A Matrix server, Vaultwarden and SearXNG together: 2 vCPU, 4 GB RAM, 80 GB NVMe, 4 TB traffic, $8.25 a month on the 12-month term and $16.50 on a single month.

For a team chat with many rooms, Night (4 vCPU, 8 GB RAM, 160 GB NVMe, 8 TB traffic, $13.50 a month on the 12-month term) is listed for A busy relay, a team chat server or several services.

Does federation need port 8448?

No, federation can run over port 443 if you delegate it. The Synapse reverse-proxy page states that with delegation through the .well-known/matrix/server response, port 8448 does not have to be opened and federation uses 443. Without delegation the default federation port is 8448, so open it in the firewall and add a second server block that listens there.

Clients can find your server through a /.well-known/matrix/client file served at https://your-server-name/.well-known/matrix/client, which names the homeserver in m.homeserver with its base_url. Browser clients also need a CORS header, and Synapse’s public_baseurl should carry the same URL. Run the server name on the bare domain only if you can serve that file there.

How do you keep a self-hosted Matrix server safe?

Back up the signing key, the database and the media store, and keep the host patched. The docs warn that the signing keys must be saved because other servers rely on them. Messages in rooms without end-to-end encryption sit readable in the database on your VPS, so disk encryption is worth considering; Can I encrypt a VPS disk with LUKS? covers what disk encryption does and does not protect.

No plan includes backups: keep your own copy of anything you cannot lose. According to Gloamport’s survey of 10 November 2026, 28 of the 49 providers ask for no ID document at sign-up, so the VPS can be bought without handing documents over, but the server security is still yours: key-only SSH, as in How do I harden SSH on a new VPS?.

In summary
  • Synapse installs from packages.matrix.org as matrix-synapse-py3.
  • The server name is permanent; choose the domain first.
  • Use PostgreSQL; the docs call SQLite acceptable for testing only.
  • Proxy /_matrix and /_synapse/client to localhost:8008 behind HTTPS.
  • Delegation lets federation use port 443 instead of 8448.
  • Gloam, $8.25 a month on 12 months, is the matching plan.
  • Back up the signing keys, the database and the media; no plan includes backups.

Hosting a Matrix server: common questions

Do I need a domain name for Matrix?

Yes. The server name is part of every user ID and is set at install. It cannot be changed afterwards, so register or choose the domain before you install.

Why not use SQLite?

The Synapse documentation says SQLite is acceptable for testing only and should not be used in production. Almost all installations should use PostgreSQL.

Where do I put my own settings?

In files under /etc/matrix-synapse/conf.d/. The docs recommend this so a package upgrade does not ask whether to replace your configuration file.

How do I create the first account?

Run register_new_matrix_user -c on the homeserver configuration after Synapse is running. It uses the registration_shared_secret, which anyone who knows can use to create accounts, admins included.

Can I run Matrix beside other services?

Yes on a Gloam or larger plan. Vaultwarden and SearXNG are small next to it; see the guide on self-hosting Vaultwarden.

Sources (3)
  1. Synapse documentation: Installation instructions — Element / Matrix.org Foundation (checked 2026-11-10)
  2. Synapse documentation: Using a reverse proxy with Synapse — Element / Matrix.org Foundation (checked 2026-11-10)
  3. Synapse documentation: Using Postgres — Element / Matrix.org Foundation (checked 2026-11-10)

From $3.74/month · no KYC

Deploy a VPS