Railway

Deploy Mattermost — Self-Hosted Slack Alternative [S3]

Self-host Mattermost — channels, threads, S3 files, Postgres

Deploy Mattermost — Self-Hosted Slack Alternative [S3]

/var/lib/postgresql/data

/mattermost/data

Deploy and Host Mattermost on Railway

Mattermost is the leading open-source, self-hosted team messaging platform — a secure Slack alternative with channels, threads, direct messages, file sharing, search, and integrations, on infrastructure you own. This template deploys Mattermost Team Edition with a managed PostgreSQL database and bundled S3-compatible file storage, so file uploads are production-safe from the first deploy — not a caveat you solve later.


What This Template Deploys

ServicePurpose
MattermostThe chat server, web app, and admin console on port 8065
PostgreSQLUsers, channels, posts, and configuration
MinIO (S3)Object storage for file uploads and images

All services run on Railway's private network. File uploads go to MinIO rather than an ephemeral volume, which is the production-storage step other templates leave to you.


About Hosting

Mattermost itself is straightforward — a Go server plus PostgreSQL. The two things that separate a working demo from a production instance are exactly the two most Railway templates tell you to handle yourself: file storage and email. This template handles the first for you.

File uploads need object storage, not a local volume. By default Mattermost writes uploads to a local directory — fragile on a container platform, where a volume misconfiguration or a host move loses your files. The production answer is S3-compatible storage, and this template bundles MinIO as that layer via MM_FILESETTINGS_DRIVERNAME=amazons3. Uploads, images, and shared files land in object storage that scales and persists independently of the app container.

Two configuration details are non-negotiable, and both are common failure points:

  • MM_SERVICESETTINGS_SITEURL must be your exact public HTTPS domain. Mattermost builds notification links, OAuth callbacks, and mobile-app connections from it. If it's wrong or unset, links break and push notifications misbehave — a subtle failure that looks like the app "mostly working."
  • The database connection string needs ?sslmode=disable. Railway's private network isn't TLS internally, so the Postgres datasource must disable SSL or the app fails to connect.

The one thing this template can't bundle is email: set up SMTP under the System Console so users receive notifications and can reset passwords. It's the last step before inviting a team.

Typical cost: ~$10–20/month on Railway across the three services. Slack charges roughly $8.75/user/month on its paid tier; at ten users that's $87/month for a product you don't own. Mattermost Team Edition is free with no user cap.


How It Compares

Mattermost (self-hosted)SlackMattermost CloudRocket.Chat
Cost modelFlat ~$10–20/mo infraPer user/monthPer user/monthSelf-host or cloud
User limitUnlimitedPer seatPer seatUnlimited
Data ownershipFullVendorMattermost cloudFull
Message historyUnlimitedCapped on freeUnlimitedUnlimited
File storageYour S3/MinIOVendorVendorYour storage
Self-hostableYesNoNoYes

Slack is the polished incumbent but caps free history and bills per seat. Rocket.Chat is a close open-source peer. Mattermost wins for teams that want a mature, Slack-familiar interface with unlimited users and history, and every message and file on infrastructure they control — the standard pick for security- and compliance-sensitive organizations.


Deploy in Under 5 Minutes

  1. Click Deploy on Railway — Mattermost, PostgreSQL, and MinIO build automatically (~3 minutes)
  2. Set MM_SERVICESETTINGS_SITEURL to your Railway public domain (exact HTTPS URL)
  3. Confirm the MM_FILESETTINGS_* variables point at the MinIO service
  4. Open your domain — the first account created becomes the system admin
  5. Configure SMTP under System Console → Environment → SMTP, then invite your team

Create channels, set up teams, and install integrations from the admin console.


Common Use Cases

  • Self-hosted Slack replacement — channels, threads, DMs, and file sharing with unlimited users and history at a flat cost
  • Security- and compliance-sensitive teams — keep every message and file on infrastructure you control, out of a vendor's cloud
  • Developer team chat — deep integrations with CI/CD, GitHub, Jira, and incident tooling, plus slash commands and bots
  • Regulated-industry messaging — healthcare, finance, and government teams that can't use a third-party SaaS chat

Configuration

VariableRequiredDescription
MM_SERVICESETTINGS_SITEURLRequiredYour exact Railway public HTTPS domain — links and notifications build from it
MM_SQLSETTINGS_DRIVERNAMEPre-setpostgres
MM_SQLSETTINGS_DATASOURCEAuto-injectedPostgres connection string with ?sslmode=disable for Railway's private network
MM_FILESETTINGS_DRIVERNAMEPre-setamazons3 — routes uploads to MinIO/S3
MM_FILESETTINGS_AMAZONS3BUCKETRequiredMinIO bucket name
MM_FILESETTINGS_AMAZONS3ENDPOINTRequiredMinIO service endpoint
MM_FILESETTINGS_AMAZONS3ACCESSKEYIDRequiredS3 access key
MM_FILESETTINGS_AMAZONS3SECRETACCESSKEYRequiredS3 secret key
MM_SERVICESETTINGS_LISTENPORTPre-set8065

MM_SERVICESETTINGS_SITEURL must match your real domain exactly. Notification links, OAuth callbacks, and mobile connections are built from it. A wrong or empty value makes the app appear to work while links and push notifications quietly break.

File storage uses MinIO, not a volume. Uploads route to bundled S3-compatible object storage via MM_FILESETTINGS_DRIVERNAME=amazons3, so files persist and scale independently of the app — the production step other templates leave to you.


Dependencies for Mattermost Hosting

  • Railway account — expect ~$10–20/month across the three services
  • Bundled MinIO for S3-compatible file storage (included)
  • SMTP credentials for email notifications and password resets
  • Optional: a custom domain for a branded chat URL

Deployment Dependencies

Implementation Details

The template runs the mattermost/mattermost-team-edition image on port 8065 against a managed Railway PostgreSQL service and a MinIO service for object storage. The Postgres datasource is assembled from Railway reference variables with ?sslmode=disable, required because the private network isn't TLS-encrypted internally and the app otherwise fails to connect.

File storage is configured for S3 rather than the local default: MM_FILESETTINGS_DRIVERNAME=amazons3 points at the bundled MinIO service, so uploads persist in object storage independently of the app container. This is the production step Mattermost's own guidance flags and most templates leave unconfigured — files on an ephemeral volume are the common way self-hosted Mattermost loses data.

MM_SERVICESETTINGS_SITEURL is set to the public domain, since Mattermost derives notification links, OAuth callbacks, and mobile connectivity from it. The image is Team Edition — free and unlimited — and can be switched to Enterprise Edition later without data loss if you need AD/LDAP, SSO, or compliance exports under a licence.


Frequently Asked Questions

Why bundle MinIO instead of using a volume for files? Mattermost defaults to local file storage, which is fragile on a container platform — a volume issue and uploads are lost. This template uses bundled MinIO (S3-compatible) so files persist and scale independently, the production step most templates skip.

My links or notifications are broken — why? Almost always because MM_SERVICESETTINGS_SITEURL doesn't match your real domain. Mattermost builds every link from it, so set it to your exact Railway HTTPS URL.

Why does the database connection need sslmode=disable? Railway's private network isn't TLS-encrypted internally, so the Postgres datasource must disable SSL. With it enabled, Mattermost can't connect.

Is Team Edition really free and unlimited? Yes. Team Edition has no user cap or licence fee and runs indefinitely. Enterprise Edition adds AD/LDAP, SSO, compliance exports, and HA clustering under a paid licence — you can switch images later without losing data.

Do I need SMTP? For email notifications and password resets, yes. Configure it under System Console → Environment → SMTP. Chat works without it, but password resets won't.

Do my messages and files survive a redeploy? Yes. Messages live in PostgreSQL and files in MinIO, both backed by Railway services that persist across redeploys. Back both up on a schedule.

How many users can it handle? A small deployment serves a team comfortably; Mattermost scales to thousands with more resources. Raise Railway's CPU and memory as concurrency grows.


Why Deploy 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 a self-hosted Slack alternative that's production-shaped from the first click — Mattermost, PostgreSQL, and MinIO pre-wired over a private network, S3 file storage configured, the site URL and SSL mode set correctly, and automatic HTTPS. Unlimited users and history, every message and file on infrastructure you own.


Template Content

More templates in this category

View Template
Telegram JavaScript Bot
A template for Telegram bot in JavaScript using grammY

Agampreet Singh
295
View Template
Cobalt Tools [Updated Jul ’26]
Cobalt Tools [Jul ’26] (Media Downloader, Converter & Automation) Self Host

shinyduo
248
View Template
Telegram Gateway
Multi-bot Telegram webhook gateway with real-time WebSocket event streaming

INAPP
5