Deploy Stalwart

Persistent Stalwart mail and collaboration server with HTTPS setup. Read Railway SMTP/TCP limitations before deploying.

Deploy Stalwart

Just deployed

/var/lib/stalwart

Deploy Stalwart on Railway

Stalwart provides mail and collaboration protocols including JMAP, IMAP, POP3, and SMTP. This template runs the official stalwartlabs/stalwart:v1.1.1 image, the latest stable release verified on November 17, 2026.

Read before deploying: Railway is not a drop-in host for a conventional public MX server. The included HTTPS domain serves the setup wizard, WebUI, and HTTP-based protocols; it does not expose SMTP or IMAP. Internet mail delivery requires additional networking and, typically, an external SMTP relay or mail gateway. If you need direct inbound SMTP on port 25, a fixed mail-server IP, or control of reverse DNS, use infrastructure that explicitly supports those requirements.

Persistent configuration and data

The volume is mounted at /var/lib/stalwart. CONFIG_PATH=/var/lib/stalwart/config.json puts the bootstrap configuration on that same volume, alongside the server data. This is intentional: the upstream default /etc/stalwart/config.json would otherwise live on an ephemeral filesystem on Railway, causing a fresh setup wizard after container replacement.

Keep the data store, blobs, and any local log files you select in the wizard under /var/lib/stalwart, or use explicitly configured external services. Keep one replica for the local store. A weekly volume backup schedule is included; review retention, cost, and restore procedures before relying on it.

Railway volumes are root-owned. RAILWAY_RUN_UID=0 avoids startup permission errors with the official image's non-root default. Removing it requires correctly provisioning writable volume ownership first. The template retains the upstream entrypoint and does not run chmod 777 or download dependencies at startup.

First deployment

  1. Open the service logs and retrieve the administrator credentials generated by Stalwart. Do not publish logs containing credentials.
  2. Open the generated HTTPS domain and complete the setup wizard promptly. The bootstrap listener has different security properties from the normal server; do not leave an unfinished setup publicly exposed.
  3. Set the mail hostname to a domain you control. This is separate from the Railway web domain. Choose persistent local storage under /var/lib/stalwart or configure external stores deliberately.
  4. Keep a plain HTTP listener on 0.0.0.0:8080 in the normal server configuration. Railway terminates public TLS and forwards HTTP to that port. PORT=8080 and STALWART_RECOVERY_MODE_PORT=8080 do not create a normal-operation listener for you. Removing it or changing it to HTTPS will break the Railway domain and deployment probe.
  5. Finish any requested server restart, sign in to the WebUI, and verify both the published URL and application readiness. Configure trusted forwarded headers according to the official reverse-proxy documentation; do not trust arbitrary clients.

STALWART_PUBLIC_URL defaults to https://${{RAILWAY_PUBLIC_DOMAIN}}. Update it when switching to a custom web domain. This variable controls published URLs, not mail DNS or listener bind addresses.

Health checks

Railway probes GET /healthz/live on port 8080, allowing an unconfigured server to reach the setup wizard without a deployment loop. The timeout is 300 seconds, and failure retries are bounded.

Liveness is not proof of mail readiness. After setup, also monitor /healthz/ready, storage access, mail delivery, queues, and the external relay. Railway's startup probe is not continuous monitoring. The marketplace health score is a separate historical metric; changing this template cannot immediately reset it.

Do not enable STALWART_RECOVERY_MODE permanently or leave a STALWART_RECOVERY_ADMIN credential in the environment as an everyday administrator password.

Mail networking and DNS

  • Railway's HTTP domain does not publish ports 25, 465, 587, 993, or other mail protocols. Only add TCP proxies deliberately; clients must use the assigned port and appropriate TLS settings.
  • MX records cannot specify a custom port. A TCP proxy with an assigned non-25 port is not a replacement for standard inbound SMTP on port 25.
  • Railway currently permits outbound SMTP only on Pro and above. Free, Trial, and Hobby deployments must not assume SMTP egress will work. Even on Pro, confirm the relay, permitted ports, sender policy, IP reputation, and reverse-DNS requirements.
  • Configure SPF, DKIM, DMARC, and MX for the actual mail-delivery architecture. A successful HTTP probe does not validate any of these.

Existing installations and upgrades

Marketplace updates affect future deployments, not existing instances. Before migrating an old deployment, back up the volume and the old /etc/stalwart/config.json, preserve the existing mail/data paths, and move that configuration to the persistent path before setting CONFIG_PATH. Do not let the server initialize a new configuration over an existing store unintentionally.

Review Stalwart's migration notes before changing major versions. The image is pinned and automatic image updates are disabled so that mail-store migrations are deliberate.

References


Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
Self-hosted virtual tabletop for role-playing games (license required)

Lucas
71
View Template
NEW
Double Commander in your browser
The Double Commander file manager in the cloud, from any device

Nermin Sabanovic
0