How to Deploy Rocket.Chat on Ubuntu 24.04
Learn how to deploy Rocket.Chat on Ubuntu 24.04 LTS with MongoDB 6.0/7.0, Node.js, Nginx reverse proxy, and automated Let's Encrypt SSL encryption.

6 min read
Learn how to deploy Rocket.Chat on Ubuntu 24.04 LTS with MongoDB 6.0/7.0, Node.js, Nginx reverse proxy, and automated Let's Encrypt SSL encryption.
- Prerequisites and Supported Releases
- Step 1: Updating System Packages and Installing Core Dependencies
- Step 2: Installing and Configuring MongoDB with Replica Set
Interactive Builder for this Guide
Build your custom nginx syntax (How to Deploy Rocket.Chat on Ubuntu 24.04)
server {
listen 80;
listen [::]:80;
server_name app.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name app.example.com;
ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
gzip on;
gzip_types text/plain text/css application/json application/javascript application/xml;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}server_nameBinds this virtual host to app.example.comreturn 301 https://...Redirects all plain HTTP requests permanently to TLS/HTTPSproxy_pass http://127.0.0.1:3000Forwards HTTP + WebSocket requests to local application serverX-Content-Type-Options / X-Frame-OptionsProtects users against MIME sniffing and clickjackingRocket.Chat is a premier open-source team communication and collaboration platform designed as an enterprise-grade self-hosted alternative to proprietary services like Slack, Microsoft Teams, and Discord. Packed with real-time text messaging, encrypted private channels, audio and video conferencing, screen sharing, guest access, omnichannel customer service integrations, and matrix federation, Rocket.Chat delivers complete organizational control over internal and external communications.
For organizations bound by strict data governance, HIPAA regulations, or GDPR privacy compliance mandates, SaaS messaging platforms present severe audit and compliance concerns. Learning how to deploy rocket.chat on ubuntu 24.04 provides your enterprise with a self-hosted, secure messaging hub featuring real-time audio/video conferences, encrypted channels, and full data sovereignty.
In this comprehensive step-by-step tutorial, we demonstrate how to deploy Rocket.Chat on Ubuntu 24.04 LTS (Noble Numbat). We cover installing and configuring MongoDB with a dedicated replica set, setting up the supported Node.js JavaScript runtime, creating a dedicated system user, configuring a systemd daemon, establishing an Nginx reverse proxy with WebSocket support, and provisioning a free Let's Encrypt SSL certificate.
Deploy and configure a production-ready Rocket.Chat communication server on Ubuntu 24.04 LTS using MongoDB with replica sets, Node.js runtime, Nginx reverse proxy, and Let's Encrypt SSL.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A clean cloud VPS or dedicated server running
Ubuntu 24.04 LTS. - A non-root user account configured with administrative
sudoprivileges. - A registered domain name (e.g.,
chat.example.com) pointed to your server's public IP address. - At least
2 GB of RAM(4 GB recommended for larger teams with active video and file sharing).
Step 1: Updating System Packages and Installing Core Dependencies
Before downloading Rocket.Chat, refresh your local package repositories and install the foundational build utilities and image processing libraries required by the Node.js application.
Rocket.Chat utilizes graphicsmagick for image thumbnail generation, avatar processing, and attachment previews, along with standard build tools for compiling native npm modules.
Execute the following command to update your system and install the required tools using APT.
Verify that the required packages install without dependency errors.
# Refresh package lists and upgrade system packages
sudo apt update && sudo apt upgrade -y
# Install essential utilities and GraphicsMagick
sudo apt install -y curl gnupg build-essential graphicsmagick git
Step 2: Installing and Configuring MongoDB with Replica Set
Rocket.Chat relies on MongoDB to store messaging history, user sessions, room metadata, and channel logs. Crucially, Rocket.Chat mandates that MongoDB operates as a replica set to enable real-time Oplog tailing for instant messaging events.
Import the official MongoDB GPG key, register the MongoDB APT repository in /etc/apt/sources.list.d/mongodb-org-6.0.list, and install mongodb-org.
Next, enable replication by editing /etc/mongod.conf. Add the replication block with replSetName: "rs0", restart MongoDB, and initialize the replica set via the mongosh shell.
# Import MongoDB GPG key
curl -fsSL https://www.mongodb.org/static/pgp/server-6.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor
# Add MongoDB repository
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
# Update package lists and install MongoDB
sudo apt update
sudo apt install -y mongodb-org
# Configure replica set in /etc/mongod.conf
sudo sed -i '/#replication:/a \replication:\n replSetName: "rs0"' /etc/mongod.conf
# Enable and start MongoDB service
sudo systemctl enable --now mongod
# Initialize replica set
mongosh --eval "rs.initiate()"
Step 3: Installing the Supported Node.js Runtime
Rocket.Chat requires a specific long-term support (LTS) version of Node.js (Node.js 18 or 20 LTS depending on the Rocket.Chat major release). Using an unsupported Node.js version will prevent native C++ addons from loading properly.
Install Node.js LTS using the official NodeSource repository.
Verify that both node and npm are available on your system path, and install the pm2 or build utilities if needed.
# Download and configure NodeSource Node.js 18.x setup script
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
# Install Node.js and verify runtime versions
sudo apt install -y nodejs
node --version
npm --version
Step 4: Creating a Dedicated System User and Downloading Rocket.Chat
For security best practices, never run Rocket.Chat under the root account. Create a dedicated system user and group named rocketchat without interactive login shell privileges.
Download the latest stable release tarball directly from Rocket.Chat's distribution server into /tmp.
Extract the archive into /opt/Rocket.Chat and install all production npm module dependencies using npm install.
Assign ownership of the application directory to the rocketchat user.
# Create dedicated system user
sudo adduser --system --group --no-create-home rocketchat
# Download latest Rocket.Chat release archive
cd /tmp
curl -L https://releases.rocket.chat/latest/download -o rocket.chat.tgz
# Extract archive into /opt/
sudo tar -xzf rocket.chat.tgz -C /opt/
sudo mv /opt/bundle /opt/Rocket.Chat
# Install production npm packages
cd /opt/Rocket.Chat/programs/server
sudo npm install --omit=dev
# Set directory permissions
sudo chown -R rocketchat:rocketchat /opt/Rocket.Chat
Step 5: Creating the Systemd Service for Rocket.Chat
To ensure that Rocket.Chat starts automatically upon server reboot and restarts automatically in the event of unexpected failures, configure a systemd service unit.
Create the unit file at /etc/systemd/system/rocketchat.service.
Define the execution environment variables, including PORT=3000, ROOT_URL=https://chat.example.com, MONGO_URL, and MONGO_OPLOG_URL pointing to your local replica set.
Reload systemd daemon, start the service, and verify its active status.
# Create systemd service unit file
sudo bash -c 'cat <<EOF > /etc/systemd/system/rocketchat.service
[Unit]
Description=Rocket.Chat Server Daemon
After=network.target mongod.service
[Service]
ExecStart=/usr/bin/node /opt/Rocket.Chat/main.js
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocketchat
Group=rocketchat
Restart=always
RestartSec=10
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs0
Environment=MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs0
Environment=ROOT_URL=https://chat.example.com
Environment=PORT=3000
Environment=BIND_IP=127.0.0.1
[Install]
WantedBy=multi-user.target
EOF'
# Reload systemd, enable and launch Rocket.Chat
sudo systemctl daemon-reload
sudo systemctl enable --now rocketchat
sudo systemctl status rocketchat --no-pager
Step 6: Configuring Nginx as a Reverse Proxy with WebSockets
Rocket.Chat communicates with clients using real-time HTTP requests and WebSockets. To provide secure TLS encryption, custom domain routing, and WebSocket upgrades, configure Nginx as a reverse proxy in front of port 3000.
Install Nginx using APT and create a server block configuration file at /etc/apache2/sites-available/rocketchat.conf or /etc/nginx/sites-available/rocketchat.conf.
Configure the required Upgrade and Connection HTTP headers for WebSocket proxying, enable the configuration, and restart Nginx.
# Install Nginx web server
sudo apt install -y nginx
# Create Nginx virtual host configuration
sudo bash -c 'cat <<EOF > /etc/nginx/sites-available/rocketchat.conf
server {
listen 80;
server_name chat.example.com;
access_log /var/log/nginx/rocketchat_access.log;
error_log /var/log/nginx/rocketchat_error.log;
location / {
proxy_pass http://127.0.0.1:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$http_host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;
}
}
EOF'
# Enable site and test syntax
sudo ln -sf /etc/nginx/sites-available/rocketchat.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Step 7: Securing Rocket.Chat with Let's Encrypt SSL via Certbot
Modern web browsers require encrypted HTTPS connections for real-time WebRTC audio/video calls, microphone access, and screen sharing permissions.
Install Certbot and the python3-certbot-nginx plugin to automate certificate acquisition and renewal.
Obtain and install a free Let's Encrypt SSL certificate for your Rocket.Chat domain.
Certbot automatically configures TLS parameters and installs an automated systemd renewal timer in /etc/cron.d/certbot.
# Install Certbot and Nginx plugin
sudo apt install -y certbot python3-certbot-nginx
# Request and apply SSL certificate
sudo certbot --nginx -d chat.example.com --non-interactive --agree-tos -m [email protected] --redirect
# Test automatic renewal
sudo certbot renew --dry-run
Step 8: Completing the Rocket.Chat Setup Wizard
With Nginx and Rocket.Chat running behind valid TLS certificates, open your web browser and navigate to https://chat.example.com.
The Rocket.Chat Setup Wizard will appear to guide you through initial provisioning.
Step 1: Create your initial Admin user account (Name, Username, Email, and master Password).
Step 2: Enter Organization info (Organization Type, Industry, Size, and Country).
Step 3: Configure Server info (Server Name, Default Language, and Server Type).
Step 4: Choose whether to register your workspace with Rocket.Chat Cloud for mobile push notifications or proceed as a standalone offline workspace.
Access URL: https://chat.example.com
Initial Screen: Rocket.Chat Setup Wizard
Step 1: Admin Account Creation
Step 2: Organization Profile
Step 3: Server Preferences
Step 4: Cloud Registration (Optional)
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
Rocket.Chat fails to start with 'MongoServerError: not primary and secondaryOk=false'
Resolution: This indicates MongoDB replication is not properly initialized. Open the MongoDB shell with mongosh and execute rs.initiate(). Verify replica status by running rs.status().
Real-time messages and notifications do not appear without refreshing the browser
Resolution: This occurs when WebSocket proxying is misconfigured. Ensure your Nginx configuration contains proxy_set_header Upgrade \$http_upgrade; and proxy_set_header Connection "upgrade"; within the location / block.
Service status shows 'Error: Cannot find module fibers' or native build crashes
Resolution: Ensure you are running the exact supported Node.js LTS version (such as Node.js 18.x). Run cd /opt/Rocket.Chat/programs/server && sudo npm install --omit=dev to recompile native binary extensions.
Security Best Practices and Hardening
Always bind Rocket.Chat to localhost (127.0.0.1:3000) so that direct unencrypted access to port 3000 is blocked from external networks.
Enable Two-Factor Authentication (2FA) for all administrative accounts in Administration > Workspace > Settings > Accounts > Two Factor Authentication.
Never run Rocket.Chat under the root user account; use the unprivileged rocketchat system user.
Regularly backup MongoDB databases using mongodump and keep the underlying Ubuntu system patched.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
sudo systemctl stop rocketchat, download the new release tarball to /tmp, extract it over /opt/Rocket.Chat, re-run npm install --omit=dev in /opt/Rocket.Chat/programs/server, and restart the service.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides
Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!