On this page
- How big should a Mattermost server be?
- How do you prepare the deployment folder?
- How do you keep the app port private and start it?
- How do you configure Nginx with WebSockets?
- Which firewall ports does Mattermost need?
- How do you finish setup in the browser?
- How do you enable email notifications?
- How do you back up and upgrade Mattermost?
- What are typical Mattermost issues?
- Questions
How big should a Mattermost server be?
Mattermost with PostgreSQL on the same machine needs at least 2 GB of memory for a small team; 4 GB keeps search, file previews and plugins responsive for a few dozen active users. Message history is compact, but uploaded files grow steadily, so leave disk headroom.
You need Ubuntu 24.04, Ubuntu 22.04, Debian 12 or Debian 13 with Docker Engine and the Compose plugin (install it first), plus a DNS name such as chat.example.net. Mattermost also offers an apt repository for Ubuntu; the Docker route below works the same on all four systems.
How do you prepare the deployment folder?
cd /opt
sudo git clone https://github.com/mattermost/docker mattermost
sudo chown -R deploy:deploy /opt/mattermost
cd /opt/mattermost
cp env.example .env
nano .envIn .env, change these lines and leave the rest at their defaults for now:
DOMAIN=chat.example.net
TZ=UTC
POSTGRES_PASSWORD=a-long-random-db-pass
MATTERMOST_IMAGE_TAG=pick-a-current-releaseUse a current release number from the Mattermost changelog for the image tag; extended support releases (ESR) are the calmer choice for production. Then create the data folders and hand them to the user ID the container runs as:
mkdir -p ./volumes/app/mattermost/{config,data,logs,plugins,client/plugins,bleve-indexes}
sudo chown -R 2000:2000 ./volumes/app/mattermostHow do you keep the app port private and start it?
The without-nginx overlay publishes port 8065 for your own proxy, plus port 8443 for Calls. Edit docker-compose.without-nginx.yml so the web port listens only on loopback:
ports:
- "127.0.0.1:${APP_PORT}:8065"
- "${CALLS_PORT}:${CALLS_PORT}/udp"
- "${CALLS_PORT}:${CALLS_PORT}/tcp"Then bring the stack up:
docker compose -f docker-compose.yml -f docker-compose.without-nginx.yml up -d
docker compose -f docker-compose.yml -f docker-compose.without-nginx.yml ps
curl -s http://127.0.0.1:8065/api/v4/system/pingA JSON reply containing "status":"OK" confirms the server and database are talking. The running version shows in the System Console under About.
How do you configure Nginx with WebSockets?
Mattermost pushes messages over a WebSocket, so the proxy must pass the upgrade and allow long idle connections.
upstream mattermost_backend {
server 127.0.0.1:8065;
keepalive 32;
}
server {
listen 80;
listen [::]:80;
server_name chat.example.net;
client_max_body_size 100m;
location ~ /api/v[0-9]+/(users/)?websocket$ {
proxy_pass http://mattermost_backend;
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-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 600s;
}
location / {
proxy_pass http://mattermost_backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}sudo ln -s /etc/nginx/sites-available/mattermost /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d chat.example.netSave the block as /etc/nginx/sites-available/mattermost before the first command. Background reading: Nginx as a reverse proxy.
Which firewall ports does Mattermost need?
Web traffic needs 80 and 443. If you use the built-in Calls plugin for voice and screen sharing, clients also need port 8443 over UDP (with TCP as a fallback).
sudo ufw allow 'Nginx Full'
sudo ufw allow 8443/udp
sudo ufw allow 8443/tcp
sudo ufw statusDocker publishes the Calls port itself, but writing the rules keeps your UFW list an accurate record. In the System Console under Plugins, Calls, confirm the RTC server port matches.
How do you finish setup in the browser?
Open https://chat.example.net, create the first account (it becomes the system admin), and name your first team. Then visit the System Console:
- Environment, Web Server: check that Site URL reads
https://chat.example.net. - Authentication, Signup: turn off open account creation, or restrict it to your email domain, and invite people by link instead.
- Authentication, MFA: enable multi-factor authentication.
Desktop and mobile apps connect with the same address.
How do you enable email notifications?
Mattermost emails people about mentions they missed, invitations and password resets. Configure it in the System Console under Environment, SMTP. Since port 25 may be closed for outgoing mail (a support ticket can confirm before you depend on it), use an authenticated relay as covered in the SMTP relay guide: SMTP server smtp.relay.example.net, port 587, connection security STARTTLS, authentication on with the relay username and password. Press Test Connection, then set the notification sender address under Site Configuration, Notifications.
How do you back up and upgrade Mattermost?
Back up the database and the file store together:
cd /opt/mattermost
docker compose exec -T postgres pg_dump -U mmuser mattermost | gzip > ~/mm-db-$(date +%F).sql.gz
sudo tar czf ~/mm-files-$(date +%F).tar.gz volumes/app/mattermost .envThe database user and name match POSTGRES_USER and POSTGRES_DB in .env. To upgrade, read the important upgrade notes for the target version, raise MATTERMOST_IMAGE_TAG, then:
docker compose -f docker-compose.yml -f docker-compose.without-nginx.yml pull
docker compose -f docker-compose.yml -f docker-compose.without-nginx.yml up -dUpgrade step by step through ESR versions when you are several releases behind. The daily backup add-on adds a full-disk safety net.
What are typical Mattermost issues?
- "Cannot connect to the server" banner: WebSocket requests are not reaching port 8065 with the upgrade headers.
- Container restarts with permission errors: the volume folders are not owned by UID 2000.
- Calls connect but no audio: UDP 8443 is blocked, or the plugin is announcing the wrong public address; set the ICE host override to
198.51.100.24. - Upload rejected: raise
client_max_body_sizeand Maximum File Size in the console.
Other chat and team tools are listed under self-hosting.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Mattermost team chat
Is Mattermost free to self-host?
Yes. Without a license key the server runs the free feature set; paid licenses unlock enterprise features.
Can Mattermost import from other chat tools?
Yes. It has import tools for several common chat export formats; the import runs through the mmctl command line.
Do I need the Calls port?
Only for voice calls and screen sharing through the Calls plugin. Text chat works over 443 alone.
How many users can a 4 GB server handle?
A few dozen active users with PostgreSQL on the same machine is a reasonable start. Watch memory with usage monitoring and move up a plan when needed.
Can I use the apt package instead of Docker?
Yes. Mattermost publishes an apt repository for supported Ubuntu releases. You then install PostgreSQL separately and manage the service with systemd.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- GitLab Community Edition
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- n8n workflow automation
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- HashiCorp Vault secrets server
- OpenBao secrets management
- Infisical secrets manager
- Authelia SSO and forward auth
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Metabase dashboards
- Appwrite backend server
- Self-hosted Supabase
- PocketBase backend
- RustDesk relay server
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- AFFiNE workspace
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- NetBox network inventory
- UVdesk help desk
- YetiForce CRM