---
title: "Deploy Rocket.Chat"
description: "Rocket.Chat team chat on MongoDB, admin set at deploy, sign-up off"
category: "Other"
url: https://railway.com/deploy/rocketchat-2
---

# Deploy Rocket.Chat

Rocket.Chat team chat on MongoDB, admin set at deploy, sign-up off

**[Deploy Rocket.Chat on Railway](https://railway.com/template/rocketchat-2)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/rocketchat-2/manifest.json

- **Creator:** Dektion
- **Category:** Other
- **Total deploys:** 2

## Template content

### NATS

- **Image:** nats:2.11-alpine
- **Start command:** `nats-server --addr :: --port 4222`

### MongoDB https://devicons.railway.com/i/mongodb.svg

- **Image:** mongo:8.2
- **Start command:** `/bin/bash -c '
KEY=/data/db/railway-keyfile
printf "%s" "$MONGO_KEYFILE" > "$KEY" && chmod 400 "$KEY" && chown 999:999 "$KEY"
docker-entrypoint.sh mongod --replSet rs0 --bind_ip_all --ipv6 --keyFile "$KEY" &
pid=$!
auth="-u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --authenticationDatabase admin"
until mongosh --quiet $auth --eval "db.adminCommand({ ping: 1 })" >/dev/null 2>&1; do sleep 2; done
mongosh --quiet $auth --eval "try { rs.status() } catch (e) { rs.initiate({ _id: \"rs0\", members: [{ _id: 0, host: \"$RAILWAY_PRIVATE_DOMAIN:27017\" }] }); print(\"[railway] replica set rs0 initiated\") }"
wait $pid'`

### Rocket.Chat https://raw.githubusercontent.com/RocketChat/Rocket.Chat/756135f4a99535b1bbc1f7e3779a1035dbd20450/apps/meteor/public/images/logo/android-chrome-512x512.png

- **Image:** rocketchat/rocket.chat:9.0.0
- **Start command:** `/bin/sh -c 'trap "kill \$pid 2>/dev/null; wait \$pid; exit 0" TERM INT; while true; do node main.js & pid=$!; wait $pid; echo "[railway] Rocket.Chat stopped; starting it again in 5 s"; sleep 5; done'`
- **Health check:** /api/info
- **Public domain:** Yes

## Documentation

# Deploy and Host Rocket.Chat on Railway

[Rocket.Chat](https://github.com/RocketChat/Rocket.Chat) is open-source team chat: channels, threads, direct messages, file sharing and integrations, with web, desktop and mobile apps. This template runs Rocket.Chat 9.0.0 on Railway the way upstream's Docker Compose setup does, with the admin account set at deploy.

## About Hosting Rocket.Chat

Rocket.Chat needs MongoDB running as a replica set (it reads MongoDB's oplog for real-time updates), and that's where most self-hosted setups go wrong. Here MongoDB 8.2 runs as a one-node replica set with authentication: the replica set key file comes from a generated variable, and the first start initiates the set with the service's private address, so Rocket.Chat connects over Railway's private network. NATS runs next to it, as in upstream's compose file.

A new Rocket.Chat shows a setup wizard and lets anyone register. This template creates the admin from `ADMIN_USERNAME`, the generated `ADMIN_PASS` and your email on the first start, marks the wizard as done and turns the registration form off. Add people under Administration, Users, or send invite links. Uploaded files are stored on a volume.

Before publishing I tested it on Railway. `/api/info` answered, the API returned 401 without a login, and a registration attempt was refused with "User registration is disabled". The admin signed in through the REST API with the admin role, created a channel, posted a message and uploaded a file, and both read back. Then I restarted all three services at once, which caught a problem in my first version: Rocket.Chat started before MongoDB was ready, exited ("Topology is closed") and the deploy failed. Rocket.Chat now restarts inside its container until MongoDB answers; after the restart the admin signed in and the message and the file were still there.

Idle, Rocket.Chat used about 0.7 GB of RAM, MongoDB 0.4 GB and NATS almost nothing, roughly $11 a month on Railway's usage pricing. That fits a trial account's limits only barely, so a Hobby plan is the comfortable minimum for a team.

## Common Use Cases

- A self-hosted Slack or Teams replacement for a company that wants its messages on its own server
- Customer chat and support through Rocket.Chat's omnichannel features
- Chat for a community or classroom, with mobile apps for members

## Dependencies for Rocket.Chat Hosting

None beyond Railway for chat itself. Push notifications to the mobile apps go through Rocket.Chat's cloud gateway, which needs the workspace registered with Rocket.Chat (free for small teams); email notifications need an SMTP provider, which Railway allows on the Pro plan.

### Deployment Dependencies

- Rocket.Chat: https://github.com/RocketChat/Rocket.Chat
- Upstream Docker Compose setup: https://github.com/RocketChat/rocketchat-compose
- Images: `rocketchat/rocket.chat:9.0.0`, `mongo:8.2`, `nats:2.11-alpine`

### Implementation Details

```
ROCKETCHAT_URL               # open this
ADMIN_USERNAME / ADMIN_PASS  # admin account, created on the first start
MONGO_URL                    # replica set rs0 over the private network, with auth
TRANSPORTER                  # NATS over the private network
/app/uploads                 # uploaded files, on a volume
```

If you add a custom domain, set `ROOT_URL` to it so links and the mobile apps use it.

## Why Deploy Rocket.Chat on Railway?

Your team's chat runs on infrastructure you control, with the MongoDB replica set already wired and the admin claimed before the URL goes public. Railway bills the RAM the three services use, about $11 a month for a small team at idle.


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — Self-hosted virtual tabletop for role-playing games (license required)
- [Double Commander in your browser](https://railway.com/deploy/double-commander-in-your-browser) — The Double Commander file manager in the cloud, from any device

Open this page in a browser: https://railway.com/deploy/rocketchat-2
