Deploy Mattermost: Self-Hosted Slack Alternative for Team Chat
Private team chat with channels, threads, search and file sharing.
Just deployed
/var/lib/postgresql/data
Mattermost
Just deployed
mattermost-files
Bucket
Just deployed
Deploy and Host Mattermost on Railway
Mattermost is an open source team messaging platform for organisations that want Slack-style chat on infrastructure they control. It has public and private channels, direct and group messages, threaded replies, file sharing, full-text search, emoji reactions, webhooks, slash commands and bots, with desktop apps for Windows, macOS and Linux and mobile apps for iOS and Android. About 39,600 GitHub stars back it, and it's used by engineering, security and government teams that can't put their conversations in someone else's cloud. This template runs Mattermost Team Edition on Railway with PostgreSQL for messages and settings and a Railway object storage bucket for uploads, so the app service itself is stateless and safe to redeploy. Your whole team chats for a flat hosting bill of roughly $10–25/month instead of a per-user subscription, and message history never expires.
What This Template Deploys
| Service | Purpose |
|---|---|
| Mattermost | mattermost/mattermost-team-edition:11.9 on port 8065 with a public domain. Web app, API, WebSockets and the System Console. |
| Postgres | PostgreSQL 18 with a volume. Users, teams, channels, messages and the server configuration. |
| mattermost-files bucket | Railway object storage, S3-compatible. File uploads, images, avatars and plugins. |
Mattermost stores its configuration in Postgres (MM_CONFIG), so changes you make in the System Console survive redeploys without a config file or volume on the app service.
About Hosting Mattermost
Chat is where decisions, incident timelines, customer details and credentials end up. Hosting it yourself means that history stays in your database, under your retention rules, with no per-seat bill that grows every time you add a contractor.
Stateless app, durable data. Messages and settings live in Postgres, and every file goes to the bucket. The Mattermost container keeps nothing it needs on local disk, so redeploys and upgrades don't lose data.
First user is the admin. The first account created on a fresh deploy becomes the system admin. Sign up right away, create your team, then decide in the System Console whether others join by open sign-up, invite link or email domain.
Real client IPs. The template trusts the X-Forwarded-For and X-Real-IP headers from Railway's proxy, so audit logs and rate limits see real client addresses rather than the proxy.
Integrations. Incoming and outgoing webhooks are Slack-compatible, so many existing Slack scripts work with only a URL change. Plugins from the Marketplace in the System Console add integrations such as GitHub, GitLab, Jira and Zoom.
Importing from Slack. The mmctl tool can import users, channels and message history from a Slack export, so moving over doesn't mean starting from zero.
Notifications need email. Mattermost works without SMTP, but email notifications, invitations and password resets need it. Add an SMTP provider in the System Console when you're ready.
Mobile push. The official mobile apps connect to your server URL. Push notifications go through Mattermost's push proxy, which you enable in the System Console.
Typical cost: ~$10–25/month on Railway for Mattermost, Postgres and the bucket for a small to medium team, with no per-user fees. Slack's free plan keeps only 90 days of history, and its paid plans charge per user.
Deploy Mattermost in Under 5 Minutes
- Click Deploy on Railway. Postgres, the bucket and Mattermost start together.
- Open the public domain and create the first account. It becomes the system admin.
- Create your team, then open System Console to set sign-up rules, site name and branding.
- Add SMTP under Environment and SMTP so invitations and email notifications work.
- Invite your team and install the desktop and mobile apps, pointing them at your domain.
Upload a file in a channel to confirm the bucket is wired up; it should preview and download normally.
Common Use Cases
- Replace Slack for a company. Keep every message and file on your own infrastructure with unlimited history.
- Engineering and DevOps chat. Pipe alerts, deploys and CI results into channels with incoming webhooks.
- Incident response. Run war rooms with threads, pinned messages and searchable timelines.
- Regulated industries. Keep sensitive conversations under your own retention and access policies.
- Open source communities. Host a public community server without per-member pricing.
- Agencies and clients. Give each client a private team or shared channels.
- Remote and hybrid teams. One place for announcements, team channels and quick DMs across time zones.
- ChatOps bots. Build slash commands and bots that query internal systems from chat.
Configuration
| Variable | Required | Description |
|---|---|---|
MM_SQLSETTINGS_DATASOURCE | ✅ Auto-injected | Postgres connection for application data. |
MM_CONFIG | ✅ Auto-injected | Stores the server configuration in Postgres. |
MM_SQLSETTINGS_DRIVERNAME | ✅ Set | postgres. |
MM_SERVICESETTINGS_SITEURL | ✅ Auto-set | https:// plus the Railway domain. Used in links, emails and OAuth. |
MM_SERVICESETTINGS_LISTENADDRESS, PORT | ✅ Set | :8065 and 8065. |
MM_FILESETTINGS_DRIVERNAME | ✅ Set | amazons3, files go to the bucket. |
MM_FILESETTINGS_AMAZONS3* | ✅ Auto-injected | Bucket name, region, keys and endpoint from the Railway bucket. |
MM_SERVICESETTINGS_TRUSTEDPROXYIPHEADER | ✅ Set | Reads real client IPs from Railway's proxy headers. |
TZ | ✅ Set | UTC. |
Custom domain. Add your domain to the Mattermost service, then update MM_SERVICESETTINGS_SITEURL and redeploy so links and notifications use it.
Scaling up. Team Edition runs as a single app node, so give Mattermost and Postgres more RAM as your team grows rather than adding replicas.
More settings. Nearly every Mattermost setting can also be set with an MM_ environment variable, which then locks it in the System Console.
Mattermost vs. Alternatives
| Mattermost on Railway | Slack | Microsoft Teams | Rocket.Chat | |
|---|---|---|---|---|
| Monthly cost | ~$10–25 flat | Per user | Per user, Microsoft 365 | Self-host costs |
| Self-hosted | ✅ Yes | ❌ No | ❌ No | ✅ Yes |
| Unlimited message history | ✅ Yes | ⚠️ 90 days on free | ✅ Yes | ✅ Yes |
| Desktop and mobile apps | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
| Data in your own database | ✅ Postgres | ❌ Hosted | ❌ Hosted | ✅ MongoDB |
| Webhooks, bots and slash commands | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
| License | ✅ AGPL-3.0 source, MIT binaries | ❌ Proprietary | ❌ Proprietary | ✅ MIT core |
Dependencies for Mattermost Hosting
- Railway account. Hobby fits small teams; Pro for larger ones and more RAM.
- An SMTP provider for invitations, notifications and password resets.
- Optional: a Slack export if you're migrating history.
- Optional: an OAuth or GitLab provider if you want single sign-on.
Deployment Dependencies
- Mattermost on GitHub: source code and releases
- Mattermost docs: administration and configuration
- Mattermost apps: desktop and mobile clients
- Railway Private Networking: how services connect
Implementation Details
The image is pinned to Team Edition 11.9; the 12.x series is now available. To upgrade, back up Postgres, change the tag and redeploy, moving one major version at a time. Railway checks /api/v4/system/ping before routing traffic, so a new version only goes live once it's healthy. Postgres and Mattermost talk over Railway's private network; only Mattermost has a public domain. Railway's draining window gives Postgres 60 seconds to shut down cleanly on redeploys.
Frequently Asked Questions
What is Mattermost? An open source, self-hosted team chat platform with channels, threads, file sharing, search, integrations and desktop and mobile apps.
How much does it cost compared with Slack? About $10–25/month on Railway for your whole team, with no per-user fees. Slack charges per user on paid plans and limits history on the free plan.
Who becomes the admin? The first account created on a fresh deploy. Sign up immediately, then set sign-up rules in the System Console.
Where are files stored? In the Railway object storage bucket created with the template. Messages and settings are in Postgres.
Do the mobile apps work? Yes. Install the official iOS or Android app and enter your server URL. Enable push notifications in the System Console.
Is Team Edition free? Yes. Mattermost publishes Team Edition binaries under the MIT license. Enterprise features such as SSO with SAML and compliance exports need a paid licence.
Why Deploy and Host Mattermost on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Mattermost on Railway, you get private team chat with unlimited history and file storage, on infrastructure you control, for a flat monthly cost.
Template Content
Mattermost
mattermost/mattermost-team-edition:11.9mattermost-files
Bucket
