Why self-host Mattermost on a VPS
SaaS messaging tools bill per active user and keep the history of your exchanges on their servers. Mattermost reverses this logic: a self-hosted instance on a VPS hosts entire teams with no per-seat cost on the Team edition, with full history on the Team edition and file storage that you control. For an agency or a company subject to confidentiality constraints, hosting your messaging in-house means that neither the messages, nor the shared files, nor the metadata pass through a third party. Mattermost also integrates natively with Git forges, CI/CD tools and inbound/outbound webhooks, making it a central communication hub for technical teams.
Concrete benefits of a self-hosted Mattermost
- Full message history on the Team edition — note that the free Entry edition caps viewable history at 10,000 messages since version 11 (see below).
- Storage of shared files on your VPS or an S3 bucket you control.
- Inbound/outbound webhooks and slash commands to hook up CI, monitoring and alerts.
- Enterprise authentication: LDAP/AD, SAML and OAuth depending on the edition.
- Official desktop and mobile apps pointing to your own domain.
- Data compliance and sovereignty: no conversation outside your infrastructure.
Hardware and software prerequisites
Mattermost is more demanding than a Git forge because it maintains persistent WebSocket connections. Count on a VPS with 2 vCPU and 4 GB of RAM for a team of up to 50 active users; aim for 8 GB beyond that or if you enable advanced search. PostgreSQL is the recommended database. Plan for at least 30 GB of SSD, more if you store many files locally. On the software side: Docker and Docker Compose, a chat.yourdomain.com subdomain with an A record, and a reverse proxy able to relay WebSocket connections correctly (Upgrade/Connection).
Deploy Mattermost with Docker and SSL
Prepare the VPS
Install Docker and Compose, then fetch the official mattermost-docker repository or create /opt/mattermost. Increase vm.max_map_count and the open file limits if needed; Mattermost opens many simultaneous connections.
Configure PostgreSQL and the volumes
In the docker-compose.yml, declare a postgres service with a strong password and persistent volumes for /var/lib/postgresql/data. For Mattermost, mount dedicated volumes for config, data, logs and plugins to keep everything outside the container.
Launch the Mattermost stack
Fill in the MM_SQLSETTINGS_DATASOURCE and MM_SERVICESETTINGS_SITEURL (in HTTPS) variables, then run docker compose up -d. Follow docker compose logs -f until the message indicating that the server is listening on port 8065.
Configure the reverse proxy with WebSocket
With Nginx, proxy to http://127.0.0.1:8065 and be sure to add proxy_set_header Upgrade $http_upgrade; and proxy_set_header Connection "upgrade";, otherwise real time will not work. With Caddy, reverse_proxy localhost:8065 handles the WebSocket automatically.
Enable the SSL certificate
Obtain the certificate with certbot --nginx -d chat.yourdomain.com or let Caddy provision it on its own. Check that SiteURL is indeed in https:// in the configuration, otherwise mobile clients will refuse to connect.
Create the team and harden the instance
Open https://chat.yourdomain.com, create the system administrator account and your first team. Disable open registration, configure SMTP for notification emails, and restrict team creation to administrators.
Logging in for the first time
Open the URL as soon as the installation finishes: Mattermost displays an account-creation screen, and the VERY FIRST account created is automatically given the system administrator role. Create it immediately.
What the free edition caps since version 11
From Mattermost 11 onward, the free self-hosted edition — named Entry — caps viewable history at 10,000 messages, across all channels and for the whole server. The part most often misread: older messages are not deleted. They stay in your database, on your machine — they simply stop being viewable and searchable from the application. The change landed badly with the community, precisely because it restricts data the user hosts themselves. There are two ways out: move to a paid edition to lift the cap, or pick a tool whose free edition does not limit history. If your use case is long-running team messaging, measure your monthly volume before committing: 10,000 messages go fast with a few people. There is a third path, often overlooked: the Team edition, also free, does NOT cap history — but it has no SSO and stops at 250 users. So the choice is between a history cap (Entry) and a user cap without SSO (Team).
For shared files, do not store everything on the VPS disk in the long run: configure Mattermost in S3-compatible object storage mode. This decouples the data volume from the size of your VPS, radically simplifies backups (the bucket is versioned independently) and eases possible horizontal scaling. Also consider enabling data retention to automatically purge old messages and control PostgreSQL growth.
The official documentation
For advanced configuration and options specific to the tool, refer to the official Mattermost documentation. This guide covers going live on a VPS; the vendor's docs remain the reference for fine-tuning, major upgrades and specific use cases.