Self-host guide

How to Self-Host Mattermost on a VPS

Install Mattermost on Ubuntu 24.04 from its signed apt repository with PostgreSQL, built-in Let's Encrypt TLS, SMTP on port 587, backups and upgrades.

Mattermost is a team messaging platform with channels, threads, file sharing, integrations and playbooks, often run as a self-hosted alternative to Slack. This guide installs it by hand on Ubuntu 24.04 from Mattermost's signed apt repository, with PostgreSQL on the same server. For HTTPS it uses Mattermost's built-in Let's Encrypt support, which Mattermost's docs suggest for servers with fewer than 200 users.

Prefer one click? Deploy Mattermost from the VeloxaHost marketplace and skip the manual steps; this guide is for when you want to run every command yourself.

What you need

  • A VeloxaHost server with the Ubuntu 24.04 LTS image. You get root, over SSH or in the browser terminal on the server's page.
  • A subdomain such as chat.example.com and a dedicated IPv4 address. Mattermost serves HTTPS on port 443 and needs port 80 reachable for its Let's Encrypt challenge, and the shared IPv4 address offers neither, only a block of forwarded ports. A dedicated IPv4 is a paid add-on (the console shows the current price): choose it as "Network access" on the create page, or take one from the IP addresses page and attach it. If none is free in the region, the request is refused.
  • An email provider for invitations and notifications.

Mattermost's minimum for up to 1,000 users is 1 vCPU and 2 GB of RAM for the application, with PostgreSQL 14 or newer; Ubuntu 24.04 ships PostgreSQL 16. With the database on the same server, a Veloxa 2 (2 vCPU, 4 GB RAM, 80 GB disk) at $15 a month, billed at $0.03 an hour and capped at the monthly price, is a comfortable start. Uploaded files grow the disk over time.

Install Mattermost

  1. Make the server answer on its dedicated IPv4. Add the address to the interface (check the name with ip addr) and to the network configuration so it survives a reboot. Then create an A record for chat.example.com pointing at it. IPv6 is not available in US East yet, so skip the AAAA record there.

    ip addr add 198.51.100.5/32 dev eth0
    
  2. Install PostgreSQL from Ubuntu's archive, as PostgreSQL's download page shows.

    sudo apt update
    sudo apt install postgresql
    
  3. Create the database and its user, following Mattermost's database preparation page. Open the PostgreSQL shell:

    sudo -u postgres psql
    

    Then run these statements, with a strong password of your own. The last block is required on PostgreSQL 15 and later.

    CREATE DATABASE mattermost WITH ENCODING 'UTF8' LC_COLLATE='en_US.UTF-8' LC_CTYPE='en_US.UTF-8' TEMPLATE=template0;
    CREATE USER mmuser WITH PASSWORD 'mmuser-password';
    GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser;
    ALTER DATABASE mattermost OWNER TO mmuser;
    \c mattermost
    ALTER SCHEMA public OWNER TO mmuser;
    GRANT USAGE, CREATE ON SCHEMA public TO mmuser;
    

    Leave with \q.

  4. Add Mattermost's repository and install the server. With the mattermost argument, the setup script adds only the Mattermost repository.

    curl -o- https://deb.packages.mattermost.com/repo-setup.sh | sudo bash -s mattermost
    sudo apt update
    sudo apt install mattermost -y
    

    The package installs into /opt/mattermost, creates a mattermost user and group, and adds a systemd unit that is not yet active.

  5. Create the config file from the sample, with the permissions the docs give:

    sudo install -C -m 600 -o mattermost -g mattermost /opt/mattermost/config/config.defaults.json /opt/mattermost/config/config.json
    
  6. Edit /opt/mattermost/config/config.json with sudo nano. Under SqlSettings, set the database:

    "DriverName": "postgres",
    "DataSource": "postgres://mmuser:mmuser-password@localhost:5432/mattermost?sslmode=disable&connect_timeout=10",
    

    Under ServiceSettings, set the site URL and turn on TLS with Let's Encrypt. These keys are the config.json names of the System Console settings in Mattermost's TLS page; setting them in the file before the first start is our shortcut, so the first visit is already over HTTPS.

    "SiteURL": "https://chat.example.com",
    "ListenAddress": ":443",
    "ConnectionSecurity": "TLS",
    "UseLetsEncrypt": true,
    "Forward80To443": true,
    
  7. Let Mattermost bind to ports below 1024, then start it and enable it at boot.

    sudo setcap cap_net_bind_service=+ep /opt/mattermost/bin/mattermost
    sudo systemctl start mattermost
    sudo systemctl enable mattermost.service
    

    The docs suggest adding After=postgresql.service and BindsTo=postgresql.service to the unit's [Unit] section when the database runs on the same server. sudo systemctl edit mattermost creates a drop-in for that.

Mattermost requests its certificate the first time a browser connects to the domain.

First login

Open https://chat.example.com right after the first start. The first account you create becomes the system admin, so do not leave this step for later. Create your team, then open the System Console.

  • Environment, SMTP: enter your provider's server. Outbound TCP port 25 is blocked by default, so use port 587 with STARTTLS or 465 with TLS. Without email, invitations and notifications do not go out.
  • Site Configuration, Notifications: set a Support Email address, as the install page recommends. Notification emails show it to users who need help.
  • Authentication, Signup: leave Enable Open Server off, the default, so people need an invitation to create an account.

Secure it

In the console, go to Firewalls, New Firewall, Add Rule. Allow TCP 80 and 443 from 0.0.0.0/0 and TCP 22 only from YOUR.IP/32, then attach the firewall on the server's page. Until one is attached, all traffic is allowed. Port 80 must stay open: Mattermost uses it for the certificate challenge and to redirect to HTTPS.

From Mattermost's settings reference:

  • Authentication, MFA: turn on multi-factor authentication. It is off by default; once on, users who sign in with an email address can add it to their accounts. Add it to your admin account first.
  • Keep config.json at mode 600 and owned by mattermost, as created in step 5. It holds the database password.
  • PostgreSQL on Ubuntu listens on localhost only. Leave it that way; the remote-connection steps in Mattermost's docs are for a database on a separate server.

Back it up

Mattermost's backup page lists three things to save separately: the database, the config directory, and uploaded files in data. It also says to stop Mattermost during the backup, or the database and files can drift apart. The dump uses pg_dump as in PostgreSQL's docs; the exact commands are ours:

sudo systemctl stop mattermost
sudo -u postgres pg_dump mattermost > /root/mattermost-db-$(date +%F).sql
sudo tar czf /root/mattermost-files-$(date +%F).tar.gz -C /opt/mattermost config data
sudo systemctl start mattermost

To restore, put back the database, config.json and the data folder in the same places.

On VeloxaHost, snapshots are instant and free (5 on Starter, 30 on Pay as you go): server page, Snapshots, name, Create. Restoring overwrites the current state. Automatic snapshots run every hour, 6 hours, 12 hours, daily or weekly, kept for 1, 3, 7, 14 or 30 days. The Backups page creates, downloads and restores server backups (as a new server), on a schedule of every 6 hours, 12 hours, daily or weekly, keeping 1 to 10. Download one now and then for an off-site copy.

Update it

Take a snapshot, and read Mattermost's important upgrade notes for every version you skip. The install page's upgrade is apt, with Mattermost stopped first:

sudo systemctl stop mattermost
sudo apt update && sudo apt upgrade

An upgrade replaces the mattermost binary, and with it the permission to bind port 443 that setcap gave the old file. Run the setcap line from step 7 again, then start Mattermost. That step is our addition.

sudo setcap cap_net_bind_service=+ep /opt/mattermost/bin/mattermost
sudo systemctl start mattermost

The newest server release on GitHub was 12.0.0 when checked.

Troubleshooting

invalid LC_COLLATE locale name: "en_US.UTF-8". Generate the locale with locale-gen en_US.UTF-8, then create the database again.

No certificate. Check that the A record points at the dedicated IPv4, the address is on the interface, ports 80 and 443 are open in the firewall, and Forward80To443 is true.

Mattermost will not start after an upgrade. It cannot bind port 443. Run the setcap command again.

Email notification links are broken, or OAuth logins fail. Site URL is empty or wrong; Mattermost's docs mark it as required.

Anything else. Read journalctl -u mattermost and /opt/mattermost/logs/mattermost.log.

FAQ

What license is Mattermost under?

Mattermost, Inc. licenses its compiled releases, which this repository installs, under the MIT license. The source code is available under the AGPL v3.0 or a commercial license. Paid plans unlock further features with a license key.

Do I need a dedicated IPv4 address?

For this setup, yes. Mattermost serves HTTPS on port 443 and completes the Let's Encrypt challenge through port 80, and the shared IPv4 address only offers a block of forwarded ports.

Should I put NGINX in front of Mattermost?

Mattermost recommends a proxy such as NGINX above about 200 users, or when you need load balancing, caching or request logs. Below that, its built-in TLS is the simpler setup. If you add a proxy later, switch Mattermost's own TLS off first.

Where are my messages and files stored?

Messages, users and channels are in the PostgreSQL mattermost database. Uploaded files are in /opt/mattermost/data unless you point file storage at S3-compatible object storage in the System Console.

Which VeloxaHost size fits Mattermost?

Mattermost gives 1 vCPU and 2 GB of RAM for the application with up to 1,000 users. With PostgreSQL on the same server, a Veloxa 2 (2 vCPU, 4 GB RAM, 80 GB disk) at $15 a month, billed at $0.03 an hour and capped at the monthly price, leaves room for both.

Commands and settings checked on 2026-10-19 against the official documentation: docs.mattermost.com, www.postgresql.org, github.com. Software changes; if a step no longer matches, the vendor's docs win.

Ready to deploy?

Start a free trial, or compare plans to match your team's scale.