Railway

Deploy Mattermost | Self-Hosted Team Chat with Persistent File Storage

Self-host Mattermost on Railway — channels, threads & uploads that persist.

Deploy Mattermost | Self-Hosted Team Chat with Persistent File Storage

/var/lib/postgresql/data

mattermost/mattermost-team-edition:release-11.8

mattermost/mattermost-team-edition:release-11.8

Just deployed

/mattermost/data

Deploy and Host Mattermost on Railway

Mattermost is an open-source, self-hosted team messaging platform — channels, threads, direct messages, file sharing and search, with your conversations and files staying on infrastructure you control. This template deploys Mattermost Team Edition together with a PostgreSQL database, already wired to each other over Railway's private network.

About Hosting Mattermost

Mattermost keeps two kinds of state, and both need somewhere durable to live. Messages, channels and users go into PostgreSQL. Uploaded files — attachments, avatars, images pasted into a thread — go onto disk. A container filesystem is wiped on every redeploy, so without a volume mounted at /mattermost/data those uploads disappear the first time the service restarts, while the messages referring to them stay behind as broken links. This template mounts a volume for both services, so nothing is lost on redeploy.

Common Use Cases

  • A private Slack alternative for a team that does not want its conversations on someone else's servers
  • Internal chat for organisations with data residency requirements
  • A hub for build and alert notifications via incoming webhooks and slash commands

Dependencies for Mattermost Hosting

  • mattermost/mattermost-team-edition:release-11.8 — the official image, pinned to a stable release rather than latest
  • PostgreSQL 18, provisioned by this template and connected over the private network

Deployment Dependencies

Implementation Details

The database connection is assembled from the Postgres service's own variables and resolved over railway.internal, so credentials are never duplicated and the traffic never leaves the private network:

MM_SQLSETTINGS_DATASOURCE=postgres://${{Postgres.PGUSER}}:${{Postgres.POSTGRES_PASSWORD}}@${{Postgres.RAILWAY_PRIVATE_DOMAIN}}:5432/${{Postgres.PGDATABASE}}?sslmode=disable&connect_timeout=10

MM_SERVICESETTINGS_SITEURL is bound to the generated public domain, which Mattermost needs for links, email and OAuth to be correct.

One detail worth knowing if you build your own Mattermost deployment: the official image runs as a non-root user, and a freshly mounted Railway volume is owned by root — so the server cannot write uploads to it. This template sets RAILWAY_RUN_UID=0, which is Railway's documented remedy. After deploying, /api/v4/system/ping?get_server_status=true should report database_status: OK and filestore_status: OK.

Getting Started

Open the generated domain, create the first account — it automatically becomes the System Administrator — then create a team and invite people. SMTP for email notifications is configured later under System Console → Environment → SMTP.

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 are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


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
4