Skip to content
🧮 Is Lifetime with ZapX Pass worth it? Work it out for your own servers in 30 seconds. Open the Lifetime calculator →

Set Up Mattermost on a Linux Server – Team Chat as a Self-Hosted Slack Alternative

Set up Mattermost on a Linux server as a One-Click App or with Docker Compose, then secure the admin account, invite members, connect apps, and configure SMTP.

2 December 202613 min read4 Views0 helpful

Introduction

Mattermost is an open-source team chat that you host yourself. You can chat in channels and direct messages, reply in threads, share files, and search your entire history. There are dedicated apps for Windows, macOS, Linux, Android, and iOS. This makes Mattermost a self-hosted alternative to Slack: all messages and files are stored on your own server. In this guide, we’ll show you two ways to get started: the easy way with a One-Click App, which makes Mattermost available over HTTPS in just a few clicks, and a manual installation with Docker Compose. Afterward, you’ll create your team, invite members, close registration, connect the desktop and mobile apps, and configure email notifications.

When Mattermost Makes Sense on a VPS

Mattermost is a good choice when a team communicates regularly and wants to keep control of its own data. Mattermost is a good fit on a VPS if:

  • you don’t want your messages stored with a cloud provider, for example, for privacy reasons or because of contractual requirements.
  • you don’t want to pay license fees per user. The free Team Edition is released under an open-source license and covers standard team chat.
  • you want to send notifications from your own systems to channels, for example, from monitoring, Git, or scripts using webhooks.
  • your team or community needs channels, threads, and apps for all devices, but not a public forum.
  • you want to replace Slack while keeping the familiar experience of channels, threads, and mentions.

Mattermost is less suitable if you mainly need voice and video calls or if only two or three people chat occasionally. For voice channels, for example, a TeamSpeak server is a better fit; a messenger is often enough for small groups. Mattermost requires some maintenance as a server with a database: updates, backups, and a mail server for notifications. Another self-hosted chat software in the app catalog is Rocket.Chat.

The Easy Way: Mattermost as a One-Click App

The quickest way to get started with Mattermost is through your VPS's One-Click Apps. With a domain, the app is directly accessible over HTTPS, includes its own PostgreSQL database, automatically sets the app's address, and creates your admin account during installation. You don't need to configure a reverse proxy, certificate, or firewall rules.

Requirements

  • A Linux VPS (Debian or Ubuntu) with One-Click Apps set up. See Setting Up One-Click Apps for instructions.
  • At least 2 GB of RAM; 4 GB of RAM and 2 vCPU cores are recommended. Immediately after startup, Mattermost and PostgreSQL use around 0.6 GB of RAM combined. The official documentation recommends 1 vCPU core and 2 GB of RAM for up to 1,000 users, and 2 vCPU cores and 4 GB of RAM for up to 2,000 users.
  • Make sure you have enough storage for uploaded files. The image alone is just over 1 GB.

Install

  1. Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
  2. Search the app catalog for Mattermost and click Install app.
  3. Use a custom subdomain or zap.cloud is already selected. Enter your own name, such as chat, or keep the suggested name.
  4. Under App configuration, enter the email address for your admin account in MATTERMOST_ADMIN_EMAIL. The default is admin@example.com. Use a real address that Mattermost can later use to send links for resetting your password, for example. TZ sets the time zone (default UTC), and POSTGRES_DB sets the database name (default mattermost).
  5. Click Queue installation.

On its first startup, Mattermost sets up its database. This takes a few minutes. Once the app card shows Online, you’re ready to go.

First login: Find your credentials

Mattermost is installed with a ready-to-use system administrator account. Open registration is not available, even immediately after installation. You can find the login credentials in the app settings:

  1. Click the gear icon on the app card and switch to App environment.
  2. Under Automatically generated values, find SERVICE_USER_ADMIN (username, zapx) and SERVICE_PASSWORD_ADMIN (password). Click the eye icon to show a value, or the icon beside it to copy it. The account's email address is the value of MATTERMOST_ADMIN_EMAIL you entered during installation.
  3. Open the app using the Access link. If Mattermost asks whether you want to continue in the browser or desktop app, select View in Browser.
  4. Sign in with the username or email address and password.

After signing in for the first time, create your team. Mattermost guides you through a short setup: enter your team name when asked “What’s the name of your organization?”, skip the question about tools such as GitHub or Jira by selecting Skip, then click Finish setup to open the Town Square channel in your new team.

Afterward, change your password in Mattermost by going to your profile picture > Profile > Security > Password. The other values under Automatically generated values (SERVICE_USER_POSTGRES and SERVICE_PASSWORD_POSTGRES) are for the database; you don't need them to sign in.

If you installed Mattermost before 2026-12-01 and created your own account at the time, your existing account remains in use. A zapx account will not be created.

“Preview Mode” Notice

After setup, Mattermost displays the banner “Preview Mode: Email notifications have not been configured.” The One-Click App doesn’t include a mail server. Without SMTP, Mattermost can’t send email invitations, notifications, or password reset links. See the “Email Notifications via SMTP” section below to learn how to configure your mail server. The One-Click App sets the app address (Site URL) automatically. That’s why the field is locked in the System Console.

Updates and backups

Update Mattermost in the app settings (gear icon), under App update. Click Check for updates and install a new version with Apply update. If you see “The app is already up to date.”, there isn’t a newer version in the app catalog yet.

Warning: Back up before updating

When a new version starts, Mattermost automatically updates the database. After that, you can only go back to the previous version using a backup. So back up the VPS first, for example, through Backups in the dashboard.

Messages, channels, and accounts are stored in the app’s PostgreSQL database, while uploaded files are stored in the volume for /mattermost/data. Both are preserved during updates.

Manual Installation

The rest of this guide describes a manual installation of Mattermost with Docker Compose on your VPS, for example, if you’re not using One-Click Apps on the server or want to run Mattermost behind your own reverse proxy.

Requirements

  • A Linux VPS running Debian or Ubuntu, with SSH access. See First Access via SSH.
  • Docker and Docker Compose (Compose v2). See Installing Docker. Check the installation with docker --version and docker compose version.
  • A domain or subdomain whose A record points to your VPS’s IP address (e.g. chat.example.com).

The values below are based on the official documentation (1 vCPU core and 2 GB of RAM for up to 1,000 users). Storage requirements are mainly determined by the files your team uploads.

HardwareMinimumRecommended
CPU1 vCPU core2 vCPU cores
RAM2 GB4 GB
Storage10 GB40 GB

Prepare the Firewall

Mattermost listens on port 8065 inside the container. You don’t need to open this port if you use a reverse proxy as described below. With ufw, allow only SSH and the ports required for the reverse proxy:

Code
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable
Warning: Docker bypasses ufw

Ports published by Docker with ports: are accessible from outside even when ufw blocks them. Docker adds its own rules ahead of ufw rules. So, bind Mattermost to 127.0.0.1 as described below. For more information about the firewall, see Managing the Firewall on Linux.

Install with Docker Compose

Create a directory for Mattermost, generate the database password, and create the data directories. Mattermost runs in the container with user ID 2000, so these directories must belong to that user:

Code
mkdir -p /opt/mattermost
cd /opt/mattermost
echo "POSTGRES_PASSWORD=$(openssl rand -hex 24)" > .env
chmod 600 .env
mkdir -p volumes/db volumes/app/{config,data,logs,plugins,client-plugins,bleve-indexes}
chown -R 2000:2000 volumes/app

Then create the docker-compose.yml file, for example, with nano docker-compose.yml, and add the following content. Replace chat.example.com with your domain:

Code
services:
  postgres:
    image: postgres:18-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: mmuser
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: mattermost
    volumes:
      - ./volumes/db:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U mmuser -d mattermost"]
      interval: 5s
      retries: 10

  mattermost:
    image: mattermost/mattermost-team-edition:10.11
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    ports:
      - "127.0.0.1:8065:8065"
    environment:
      TZ: Europe/Berlin
      MM_SQLSETTINGS_DRIVERNAME: postgres
      MM_SQLSETTINGS_DATASOURCE: postgres://mmuser:${POSTGRES_PASSWORD}@postgres:5432/mattermost?sslmode=disable&connect_timeout=10
      MM_SERVICESETTINGS_SITEURL: https://chat.example.com
    volumes:
      - ./volumes/app/config:/mattermost/config
      - ./volumes/app/data:/mattermost/data
      - ./volumes/app/logs:/mattermost/logs
      - ./volumes/app/plugins:/mattermost/plugins
      - ./volumes/app/client-plugins:/mattermost/client/plugins
      - ./volumes/app/bleve-indexes:/mattermost/bleve-indexes

Here’s what the important lines do:

  • mattermost-team-edition:10.11: the free Team Edition, version 10.11, an Extended Support Release (ESR). With this tag, docker compose pull downloads bug fixes for version 10.11.
  • MM_SQLSETTINGS_*: Mattermost stores everything in the PostgreSQL database in the first container.
  • MM_SERVICESETTINGS_SITEURL: the public address, including https://. Mattermost uses it to create links in emails and invitations. Mattermost will refuse to start if the address doesn’t begin with https://. Since the value is set through an environment variable, the field is locked in the System Console.
  • 127.0.0.1:8065:8065: Mattermost is accessible only from the server itself and only through the reverse proxy from outside.
  • volumes: configuration, uploaded files, logs, plugins, and the search index are stored in /opt/mattermost/volumes and are retained during updates.

Pull the images and start Mattermost:

Code
docker compose pull
docker compose up -d
docker compose logs -f mattermost

The first startup takes a while because Mattermost sets up the database. Exit the log view with Strg+C. Check that Mattermost is running with curl http://127.0.0.1:8065/api/v4/system/ping. The response contains "status":"OK".

First Visit: Securely Create the Admin Account

Since the first account becomes the system administrator, create it before Mattermost is accessible from outside. Mattermost includes the mmctl command-line tool, which works in the container without logging in (Local Mode). Create your admin account and team:

Code
cd /opt/mattermost
docker compose exec mattermost mmctl --local user create --email admin@example.com --username admin --password 'DEIN_PASSWORT' --system-admin
docker compose exec mattermost mmctl --local team create --name team --display-name "Mein Team"
docker compose exec mattermost mmctl --local team users add team admin

Replace the email address, username, password, and team name with your own values. Open registration is now disabled. New users can join only by invitation. Set up the reverse proxy in the next section, then sign in at https://chat.example.com.

Tip: Don’t leave your password in the shell history

The password is included in the command and therefore in your shell history. Change it in your Mattermost profile after signing in for the first time. You can also clear the history of the current shell with history -c.

Access via HTTPS Through a Reverse Proxy

To access Mattermost from outside, put a reverse proxy with a valid certificate in front of it. For the basics, see Setting Up a Reverse Proxy with nginx and Creating an SSL Certificate (Let's Encrypt).

Mattermost needs a WebSocket connection for real-time messaging. The proxy must forward it with the Upgrade and Connection headers. Here’s an nginx server block based on the official example:

Code
upstream mattermost {
    server 127.0.0.1:8065;
    keepalive 32;
}

server {
    listen 80;
    server_name chat.example.com;

    location ~ /api/v[0-9]+/websocket/?$ {
        proxy_pass http://mattermost;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 120s;
    }

    location / {
        proxy_pass http://mattermost;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 300s;
        client_max_body_size 101M;
    }
}

Then get the certificate with certbot --nginx -d chat.example.com. Certbot adds HTTPS and HTTP redirection to the block. client_max_body_size must be larger than the maximum file size in Mattermost (50 MB by default); otherwise, nginx will reject larger uploads.

For more tips on securing your server, see Linux Security Tips.

Back Up Your Data

Back up the PostgreSQL database and uploaded files. The database contains messages, channels, accounts, and settings; the data directory contains all files and images:

Code
cd /opt/mattermost
docker compose exec -T postgres pg_dump -U mmuser -d mattermost > mattermost-db-$(date +%F).sql
tar czf mattermost-files-$(date +%F).tar.gz volumes/app/data volumes/app/config

Also back up the .env and docker-compose.yml files. Don’t store the backup only on the VPS itself.

Update Mattermost

Back up the database and files first, and read the Important Upgrade Notes for the new version. Mattermost recommends moving between ESR versions, for example, from 10.11 to the next ESR, rather than skipping multiple versions at once. Update the version for the image in docker-compose.yml and restart Mattermost:

Code
cd /opt/mattermost
docker compose pull
docker compose up -d

When it starts, Mattermost updates the database to the new version. To see the installed version, run curl -s http://127.0.0.1:8065/api/v4/config/client?format=old and check the Version field. You can find the edition in the System Console under About > Edition and License.

Set Up Your Team and Connect Apps

After setup, you have a team with the Town Square and Off-Topic channels. Find settings for the entire server in the System Console. Open it from the grid icon in the upper left > System Console.

Invite Members

  1. Click your team’s name in the upper left and select Invite people.
  2. Click Copy invite link to copy your team’s invitation link. Anyone who opens the link can create an account and will join your team directly.
  3. To invite members who already have an account on your server, enter their details under To: and click Invite.

Email invitations work only after you’ve configured SMTP and set Enable Email Invitations to True in the System Console under Authentication > Signup. This setting is False by default.

Close Registration

Open registration is disabled by default (Enable Open Server is set to False). New accounts can only be created through an invitation link. However, anyone who gets hold of this link can use it. Here's how to close registration entirely or invalidate an old link:

  • Renew the invitation link: Team name > Team settings > Access tab > Invite Code > Regenerate. The old link will no longer work.
  • Stop all new account creation: In the System Console, go to Authentication > Signup, set Enable Account Creation to False, and click Save. Then nobody can register, even with an invitation link. When needed, you can briefly enable new user registration again or create accounts using mmctl on the console.
  • Allow only specific domains: Under Restrict new system and team members to specified email domains, enter a domain such as example.com. Only email addresses from that domain will then be allowed.

Connect the Desktop and Mobile Apps

Download the apps from the Mattermost download page. The mobile app is also available in the App Store and on Google Play under the name “Mattermost.”

  • Desktop (Windows, macOS, Linux): When you first start the app, it asks for your server address. Enter your app’s address, such as https://chat.example.com, give it a name, and sign in. The app can manage multiple servers at once.
  • Mobile (Android, iOS): When you start the app, enter the address with https:// and sign in with your account.

The apps require an address with a valid certificate. The One-Click App sets this up automatically when you use a domain. Configure push notifications on your phone in the System Console under Environment > Push Notification Server.

Email Notifications via SMTP

To send invitations, notifications, and password reset links, configure a mail server in Mattermost. You’ll need the server name, port, username, and password for an email account, for example, one from your web hosting provider.

  1. In the System Console, open Environment > SMTP.
  2. Enter the SMTP Server and SMTP Server Port (usually 465 for TLS or 587 for STARTTLS).
  3. Set Enable SMTP Authentication to True and enter the SMTP Server Username and SMTP Server Password.
  4. Under Connection Security, select TLS or STARTTLS to match the port, then click Test Connection. Click Save to save your changes.
  5. Under Site Configuration, open Notifications and set Enable Email Notifications to True. Enter the Notification Display Name, Notification From Address, and Support Email Address, then click Save.

The “Preview Mode” notice will then disappear. Use a sender address from the domain associated with the mail server you’re sending through; otherwise, emails are more likely to end up in spam.

Limitations

  • Team Edition: The free version includes channels, threads, files, search, webhooks, and apps for all devices. Features such as AD/LDAP group synchronization, advanced compliance features, and high availability require an Enterprise license.
  • No built-in mail server: Without your own SMTP access, Mattermost can’t send email notifications or password reset emails.
  • Updates in stages: For major version upgrades, move between ESR versions and always back up first.

Conclusion

With Mattermost, your team now chats on your own server instead of in someone else’s cloud, with secured registration, connected apps, and email notifications. To plan tasks as a team, the guide Set Up WeKan on a Linux Server shows you how to run your own Kanban board.

If you have any other questions or need help, our support team is available every day! 🙂

Free tools

Related tools for servers and developers

View all

FAQ

Frequently asked questions

The One-Click App is the fastest option: Mattermost is available over HTTPS on your domain within minutes, with PostgreSQL and the app address already configured. You can install updates from the dashboard, and installation creates your admin account. Manual installation with Docker Compose is a good choice if you don't use One-Click Apps on your server, want to run Mattermost behind your own reverse proxy, or want to control the version yourself. With this option, create the admin account using mmctl before Mattermost is accessible externally.
In the app settings (gear icon), go to App environment > Automatically generated values. SERVICE_USER_ADMIN is the username (zapx), and SERVICE_PASSWORD_ADMIN is the password. You can also sign in with the email address you entered under MATTERMOST_ADMIN_EMAIL during installation. SERVICE_USER_POSTGRES and SERVICE_PASSWORD_POSTGRES are for the database. Change your password in your Mattermost profile after your first login.
Click your team’s name in the upper left and select Invite people. Click Copy invite link to share a link that lets new members create an account. Email invitations work only after you configure SMTP and set Enable Email Invitations to True in the System Console under Authentication > Signup.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.