Running multiple Rocket.Chat instances with NATS

Running several Rocket.Chat instances without Kubernetes needs a shared MongoDB replica set, NATS for inter-instance messaging and a paid plan. This page explains the configuration, sequence and trade-offs.

On this page

When a single Rocket.Chat instance is no longer enough

A single Rocket.Chat instance stops being the right design when your self-hosted workspace needs more capacity or redundancy than one server can give. The answer is to run several Rocket.Chat instances behind a load balancer, all sharing one MongoDB replica set and linked to each other through NATS_URL, and to run that design on a paid Rocket.Chat plan. Rocket.Chat's reference architectures place this multi-instance pattern above 500 concurrent users. Below that point, one instance with a MongoDB replica set is the documented baseline, and it is simpler to operate.

The design sits between two other tiers. The reference architectures describe microservices on Kubernetes with the official Helm chart as the tier for loads above 5,000 concurrent users. Between roughly 500 and 5,000, you are choosing a multi-instance design without Kubernetes, which keeps the platform footprint smaller but still needs shared state, inter-instance messaging and a proxy that understands WebSocket traffic. Ask your team to confirm the expected peak concurrent users, not total headcount, because that figure drives the tier. The multi-instance and microservice designs both require a paid plan, so the licensing decision belongs in the scope before infrastructure is ordered.

Before you commit, confirm three things with your own environment in mind. First, whether your MongoDB estate can run as a three-member replica set that all instances reach. Second, whether your network lets instances reach each other on a fixed TCP_PORT and a routable INSTANCE_IP, which matters most if a firewall sits between them. Third, whether your paid plan terms and your proxy choice, such as Traefik, match your operations model. Each of these points has a cost that recurs, because you run and patch the extra instances, the database and the proxy for as long as the workspace is live.

How instances, NATS, MongoDB and Traefik connect

Users reach Traefik, which balances requests across two or more Rocket.Chat instances. Every instance reads and writes the same MongoDB replica set, and instances pass messages to each other through the server named in NATS_URL. Where a firewall sits between instances, the diagram marks the boundary where TCP_PORT must be fixed so the port can be opened. Check that each instance can reach the NATS server and the replica set members, and that INSTANCE_IP holds an address the other instances can reach.

Traffic enters through Traefik, and instances share MongoDB and NATS.

Configuration options and when each fits

This table compares the settings that connect several Rocket.Chat instances: NATS_URL, INSTANCE_IP, TCP_PORT, the shared MongoDB connection string and the Traefik load balancer. Read each row for when the setting applies and what fails if it is set wrong, since most multi-instance faults trace back to one of these five choices.

SettingWhen it appliesWhat breaks if it is wrong
NATS_URLEvery instance in the group, pointing at the same NATS server or cluster addressInstances cannot exchange messages, so presence, typing and real-time updates lag or stop reaching users on other instances
INSTANCE_IPRequired when containers do not use host networking, set to an IP other instances can reachInstances advertise an unreachable address, so peers cannot connect back and clustered traffic fails silently
TCP_PORTSet to a fixed value when a firewall sits between instances, and open that port between themA random port blocks inter-instance traffic through the firewall, so instances appear up but do not coordinate
MongoDB replica set connection stringEvery instance connects to the same replica set with all members listedInstances writing to different databases or a standalone node split workspace data, and failover of the primary interrupts all instances
Traefik load balancingSits in front of the instances to distribute client connections across themSticky routing and WebSocket headers are missing, so clients bounce between instances and lose live sessions
Paid plan entitlementRequired before running more than one instance linked by NATSWithout an eligible plan, the multi-instance setup is not supported, which the reader should confirm with Rocket.Chat before rollout

What NATS does between Rocket.Chat instances

NATS is the message bus that lets several Rocket.Chat instances behave as one workspace. Each instance receives its inter-instance traffic through the NATS_URL setting, so a message, presence change or event produced on one instance can reach users connected to another. NATS is a project of the Cloud Native Computing Foundation and is licensed under the Apache License 2.0, and its server is a single small binary with clustering, leaf nodes and other features set in configuration rather than added as separate products. Before you rely on it, confirm the NATS server version you run and the topology behind NATS_URL, including whether you run one server or a cluster and where it sits relative to your firewalls. Rocket.Chat's own multi-instance documentation at Rocket.Chat multiple instances docs is the reference for which versions it supports with your release.

Treat NATS as a separate component from the Rocket.Chat link. The link between instances is about delivering real-time events among Rocket.Chat processes. JetStream, the persistence layer in NATS, is a different feature with its own rules: it stores streams on disk or in memory and gives at-least-once delivery. Rocket.Chat's multi-instance design does not require you to change JetStream settings, so check the Rocket.Chat documentation for your release before enabling it or altering stream configuration. If you do run JetStream, the NATS documentation at NATS JetStream describes replication, and it recommends an odd number of servers, typically three or five, with R3 replication as the production floor and at most five copies of a stream.

Plan the NATS deployment as its own piece of infrastructure with an owner, a version policy and a monitoring target. Decide who patches the NATS server, how you follow its releases, and how you will detect that an instance has lost its connection to the bus. Ask your Rocket.Chat support path or implementation partner to confirm whether a single NATS server is acceptable for your user count and availability goals or whether a clustered setup is needed. Record the final NATS_URL values, the NATS server version and the topology in your runbook, so a later upgrade of Rocket.Chat or NATS can be tested against the same layout.

How to set up multiple Rocket.Chat instances with NATS

This sequence takes a single Rocket.Chat workspace from one instance to several load-balanced instances that share one MongoDB replica set and exchange messages and presence through NATS. Each step ends with a check so you know the layer works before you add the next one.

  1. Confirm the paid plan and target version

    Confirm with Rocket.Chat that your workspace is on a paid plan that permits multi-instance deployment, since the reference architectures state that multiple load-balanced instances linked by NATS require one. Then pick the Rocket.Chat release you will run on every instance, using the current line that is still supported under the version durability policy, and record it so every instance uses the same version. Done when you have written confirmation of the plan and a single pinned version number for the whole fleet.

  2. Build a three-member MongoDB 8.0 replica set

    Rocket.Chat 8.x requires MongoDB 8.0 or later running as a replica set, and a three-member replica set is strongly recommended for high availability. Your database team or a MongoDB operator builds the set, sets the replica set name, and confirms that the members can reach each other. Every Rocket.Chat instance will use the same connection string pointing at all members. Done when the replica set reports a primary and two secondaries and a test write replicates to both secondaries.

  3. Deploy the NATS server

    Run a NATS server that every Rocket.Chat instance can reach over the network. NATS is licensed under Apache 2.0 and runs on premises or in the cloud, so you can place it on infrastructure you control. Confirm the nats-server version you intend to run against the release notes, and restrict access so only your Rocket.Chat hosts can connect. For a production setup, ask your platform team whether a clustered NATS deployment is needed for your availability targets. Done when a client on one Rocket.Chat host can connect to the NATS endpoint and receive a test message.

  4. Set NATS_URL, INSTANCE_IP and TCP_PORT on each instance

    On every Rocket.Chat instance, set NATS_URL to the address of the NATS server so instances can communicate. Set INSTANCE_IP to a host IP that the other instances can reach, which is required when you are not using host networking. If a firewall sits between instances, fix TCP_PORT to a known value and open that port between the hosts, because the default port would otherwise change and the firewall would block traffic. Keep these values identical in shape across instances and differ only in host address. Done when each instance starts without connection errors in its logs and shows the others as peers.

  5. Place Traefik in front of the instances

    Deploy Traefik as the HTTP reverse proxy and load balancer in front of the Rocket.Chat instances, and route all user traffic through it. Traefik is MIT-licensed and can use file configuration, which suits a fixed set of instances. Configure TLS, forward the client address headers your Rocket.Chat configuration expects, and make sure WebSocket connections pass through, because real-time messaging depends on them. Done when requests to the public hostname are distributed across the instances and WebSocket sessions stay connected.

  6. Validate messages and presence across instances

    Create two test users and connect each one to a different instance through the load balancer. Send messages in a channel and confirm they appear immediately for both users, then change one user's status and confirm the other user sees the change. Repeat with a direct message and a file upload. Check the logs on each instance for errors from the NATS connection. Done when messages, presence and typing indicators reach every instance in both directions, and a restarted instance rejoins without losing delivery.

  7. Record the topology and failure tests

    Document the final topology: instance hosts, INSTANCE_IP values, TCP_PORT, NATS endpoint, replica set members, and Traefik configuration. Then test what happens when one instance stops and when one MongoDB member stops, and confirm users reconnect and messages still flow. Ask your team to agree on who owns each component and how upgrades will roll across instances one at a time. Done when the runbook lists each component and the failure tests have recorded results.

How the design changes by environment

In a standard Compose layout, each Rocket.Chat container has its own network namespace and is published through a reverse proxy, so other instances cannot reach it by container name alone. Set INSTANCE_IP to a host address that the other instances can route to, and point every instance at a NATS endpoint that all of them can resolve. The multiple instances guide describes the variables this depends on.

  • INSTANCE_IP: set it to the reachable host IP of the machine running each container, so peers receive an address they can connect to.
  • NATS_URL: use the same NATS endpoint on every instance and confirm each container can resolve and reach it from inside its network.
  • MongoDB connection: list all replica set members in the connection string so one member outage does not stop an instance from connecting.
  • Reverse proxy: confirm how the proxy distributes WebSocket connections across instances before you send production traffic.

After a restart, check that each instance's advertised address matches the one peers use and that the inter-instance connection appears in the logs.

Security and operational risks in a multi-instance design

Running several Rocket.Chat instances moves the risk from one application server to the links between them, the shared database and the proxy in front. Each card below names one of those points and what to check before go-live, so the design is reviewed as a whole rather than instance by instance.

NATS and MongoDB exposure between instances

NATS_URL and the shared MongoDB replica set are the paths that let instances coordinate, so they should be reachable only from the Rocket.Chat hosts and their administrators. Confirm that the NATS port and the database port are not published to user networks or the internet, that connections are authenticated, and that the MongoDB connection string used by every instance points at the same replica set. Treat any host that can reach these ports as able to affect every instance.

Multiple instances docs

Firewall rules for the fixed TCP_PORT

When a firewall sits between instances, TCP_PORT should be pinned to a known value so the rule can name it. An unpinned port can change between restarts and silently break instance-to-instance traffic. Write the rule as a pair: each instance's INSTANCE_IP and its TCP_PORT must be reachable from the other instances, and nothing else. Test the rule after every host or container change, because a reachable address that is not the host's real IP causes the same failure.

TLS at Traefik and HTTP_FORWARDED_COUNT trust

Traefik or another proxy terminates TLS in front of the instances, and Rocket.Chat must be told how many proxy hops to trust through HTTP_FORWARDED_COUNT. If the value is wrong, client addresses seen by Rocket.Chat are misread, which weakens rate limits and audit records. Check that the proxy overwrites client X-Forwarded-For headers instead of passing through what the client sent, and confirm that WebSocket traffic is routed to the instances with TLS intact.

Upgrade coordination across instances

All instances must run the same Rocket.Chat release, so an upgrade is a coordinated change rather than a rolling edit of one container. A mixed set of versions can behave differently on the same database and message bus. Plan a maintenance window, pin the release on every instance, and check the version durability page for the end-of-life date of the line you run, because unsupported versions stop receiving security fixes.

Standard release support
6 months
Version durability docs

Backups of the shared database

A multi-instance design still has one set of data. Every instance reads and writes the same MongoDB replica set, so a corrupted or deleted database affects all of them at once. Confirm that backups cover the whole replica set, that uploads kept outside MongoDB are backed up separately, and that a restore has been tested on a copy before an upgrade. Ask who owns the backup job and where the copies are stored.

Monitoring each instance

A load balancer can show a healthy front door while one instance is failing, so each instance needs its own health and log visibility. Track each instance separately, watch the NATS connection and database latency, and alert on errors that appear on only one host. Decide who receives the alerts and how a single failing instance is removed from the proxy pool without taking the others down.

Questions teams ask before running multiple instances

Do we need a paid Rocket.Chat plan to run multiple instances?

Yes. Rocket.Chat's reference architectures place multiple load-balanced instances linked by NATS above 500 concurrent users, and they state that this multi-instance design requires a paid plan. The free Starter plan covers up to 50 users and the free Community workspace covers up to 100 concurrent users with core messaging, so a deployment that needs several instances falls outside both. Confirm the exact plan tier and what it includes with Rocket.Chat before you commit, since plan terms can change between releases. Ask for the price in writing as part of your quote, because Rocket.Chat prices its paid plans by quote.

What does a multi-instance build cost, and what drives it up?

Cost has three parts: the Rocket.Chat subscription, the infrastructure you run, and the labor to build and operate it. Infrastructure includes the instances, a three-member MongoDB replica set, a NATS server, a Traefik load balancer and monitoring, all of which recur monthly or yearly depending on your hosting. Labor is largely one-time for the build and recurs for upgrades and on-call support. Costs rise with more users, higher availability targets, more environments (test and production), multiple data centers and stricter logging or backup retention. Ask any partner to split the quote into build, infrastructure handover and recurring support so you can compare it with your own team's effort.

How long does it take to set up multiple instances?

The sources supplied for this topic do not give a build duration, so no timeline can be stated here. Duration depends on how many environments you need, whether MongoDB and the reverse proxy already exist, how your firewall rules between instances are approved, and how many identity and storage integrations sit on top. Ask for a schedule that lists each milestone: environment build, database and replica set validation, instance and NATS connectivity tests, load balancer and TLS setup, and a failover test. Require the schedule to depend on your change approval windows, not only on engineering effort.

Can our in-house team build and run this without a partner?

Yes, if your team already runs MongoDB replica sets, a reverse proxy with TLS, and Linux or container hosts with firewall management. The new skills are NATS connectivity (NATS_URL, INSTANCE_IP and a fixed TCP_PORT when a firewall sits between instances), load balancer session behavior and failover testing. Assess that gap honestly. A partner is most useful for the first build, for a validated runbook and for knowledge transfer, while your team keeps day-two ownership. Whichever path you choose, confirm you can perform a rolling upgrade and a restore before go-live.

What do we need to provide before the work starts?

Plan to provide the hosting environment, network paths between instances, DNS names, TLS certificates or an ACME approach, firewall change approvals, a MongoDB replica set with three members or an agreed managed alternative, and access to your identity provider if sign-in is in scope. You also need named owners for approvals, a test environment and a maintenance window for cutover. Confirm whether your own security team must review the NATS and inter-instance traffic, since that path carries message traffic between nodes. A written scope should list these inputs so gaps show up before the build begins.

How do upgrades change a multi-instance setup?

Every instance runs the same Rocket.Chat release, so upgrades must roll across all nodes in a planned order, with the MongoDB replica set and NATS connectivity checked at each step. Rocket.Chat standard releases are supported for 6 months and LTS releases for 12 months, and an unsupported version loses security fixes and may stop connecting to the official mobile and desktop clients. Include a test upgrade against a copy of the database, a backup taken before the change, and a rollback plan. Confirm which Rocket.Chat release line your paid plan supports before scheduling the first upgrade.

Why does NATS matter if our traffic already passes through a load balancer?

The load balancer distributes client HTTP and WebSocket connections, but the instances still need a path to exchange messages with each other, and Rocket.Chat uses NATS_URL for that inter-instance communication. A NATS server failure or a misconfigured URL can split the instances' view of events, so NATS needs its own monitoring and failover planning. NATS is an Apache 2.0 project under the Cloud Native Computing Foundation, which affects licensing review, but operational ownership is what decides reliability. Ask whether the NATS deployment will be clustered and who is paged when it fails.

How DeployOpen scopes multi-instance Rocket.Chat

DeployOpen scopes a multi-instance Rocket.Chat deployment as a fixed-scope engagement, with the scope, deliverables and timeline agreed in writing before work starts. For this design, the written scope should name each instance, the shared MongoDB replica set, the NATS connection settings, the reverse proxy and the firewall rules between instances, so that the client knows exactly what is built, tested and handed over. A quote follows from that written scope, and DeployOpen does not publish a price list, so the scope document is where cost and duration get decided.

DeployOpen deploys inside the client's own infrastructure, whether that is their cloud accounts, data centers or air-gapped networks. The scope should confirm where the instances, the database and the NATS components will run, who holds the administrator accounts and secrets, and which outbound endpoints the workspace may reach. Because multi-instance designs require a paid Rocket.Chat plan, the scope also needs to confirm the plan and licensing path with the client before the build begins. Clients should ask their DeployOpen contact to write these prerequisites into the agreement.

Multi-instance Rocket.Chat changes over time, so DeployOpen also offers retainers for upgrades, ongoing support and continuous testing. Clients should confirm in the scope which Rocket.Chat release line is targeted, who runs upgrades and failover tests, and how NATS and Traefik versions are kept current, since unsupported Rocket.Chat versions stop receiving security fixes. Any retainer should be defined in writing with the same level of detail as the initial build.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.