← Back to Blog

How to Self-Host Mattermost on a VPS (2026)

Published May 3, 2026 · 7 min read · Galaxy Cloud Solutions

Slack charges $7.25 per user per month and hides your message history after 90 days on the free plan. Mattermost is open-source team chat that runs on your own server, costs nothing in per-seat fees, and keeps your messages forever. For a team of 10, self-hosting saves you $870 a year.

⚡ Deploy a VPS from $10/mo — Use code LAUNCH2026 for 50% off

Requirements

Step 1: Install PostgreSQL

sudo apt update && sudo apt install -y postgresql postgresql-contrib
sudo systemctl enable --now postgresql

Create the database:

sudo -u postgres psql << EOF
CREATE DATABASE mattermost;
CREATE USER mmuser WITH PASSWORD 'your-strong-password';
GRANT ALL PRIVILEGES ON DATABASE mattermost TO mmuser;
GRANT ALL ON SCHEMA public TO mmuser;
ALTER DATABASE mattermost OWNER TO mmuser;
EOF

Step 2: Download Mattermost

MM_VER=$(curl -s https://api.github.com/repos/mattermost/mattermost-server/releases/latest | grep tag_name | cut -d'"' -f4 | tr -d v)
wget https://releases.mattermost.com/${MM_VER}/mattermost-${MM_VER}-linux-amd64.tar.gz
sudo tar -xzf mattermost-*.tar.gz -C /opt/
sudo useradd -r -U -M -d /opt/mattermost mattermost
sudo mkdir -p /opt/mattermost/data
sudo chown -R mattermost:mattermost /opt/mattermost

Step 3: Configure the Database Connection

sudo python3 -c "
import json
with open('/opt/mattermost/config/config.json') as f:
    cfg = json.load(f)
cfg['SqlSettings']['DataSource'] = 'postgres://mmuser:[email protected]:5432/mattermost?sslmode=disable'
cfg['SqlSettings']['DriverName'] = 'postgres'
with open('/opt/mattermost/config/config.json', 'w') as f:
    json.dump(cfg, f, indent=4)
"

Step 4: Create the Systemd Service

sudo tee /etc/systemd/system/mattermost.service << EOF
[Unit]
Description=Mattermost
After=postgresql.service
Requires=postgresql.service

[Service]
User=mattermost
ExecStart=/opt/mattermost/bin/mattermost server
WorkingDirectory=/opt/mattermost
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now mattermost

Step 5: Access and Configure

Mattermost runs on port 8065. Open via SSH tunnel:

ssh -p YOUR_SSH_PORT -L 8065:localhost:8065 [email protected]

Open http://localhost:8065, create your admin account, invite your team.

One-click Mattermost installer included

Galaxy Cloud Solutions Nebula 2 plan (2GB RAM) handles Mattermost fine. One-click installer in the dashboard. Use code LAUNCH2026 for 50% off your first month.

Get Started