In this tutorial, we'll learn how to install Rocket.Chat on Debian 13 server.
Rocket.Chat is a dynamic, open-source team messaging platform designed for modern collaboration. It offers real-time chat, file sharing, and integrated video conferencing, all while giving organizations complete control over their data through self-hosting. Ideal for businesses that prioritize privacy and customization, Rocket.Chat serves as a robust alternative to proprietary messaging apps, empowering teams with secure, scalable communication solutions.
Below is a comprehensive, step-by-step guide that explains every aspect of setting up Rocket.Chat on an Debian 13 server. This guide covers installing all necessary software, configuring Rocket.Chat to run as a systemd service, setting up Nginx as a reverse proxy, and securing your installation with SSL via Let’s Encrypt.
Prerequisites:
- A Debian 13 installed dedicated server or KVM VPS.
- A root user or normal user with administrative privileges.
- A domain name point A record to server's IP
How To Install Rocket.Chat on Debian 13
Step 1. Update Your System and Prepare for Installation
Before installing anything, it’s essential to update your system’s package lists and upgrade any outdated packages. This ensures you have the latest security patches and bug fixes.
sudo apt update && sudo apt upgrade -y
This step lays a stable foundation for all subsequent installations.
Step 2. Install Node.js
Rocket.Chat is built on Node.js. While different versions may be recommended over time, at the time of writing, a stable version (for example, Node.js 22.x) is typically used.
Add the NodeSource Repository:
This command adds the Node.js repository to your system.
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
Install Node.js:
sudo apt install -y nodejs
Verify the Installation:
Check that Node.js is installed properly.
node -v
Note: Always consult Rocket.Chat’s documentation to confirm the recommended Node.js version, as it can change with new releases.
Step 3. Install and Configure MongoDB
To import the MongoDB public GPG key, run the following command:
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \
--dearmor
Create the list file for Debian 13 (Noble):
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/debian bookworm/mongodb-org/8.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
Execute following command to reload the local package database:
sudo apt-get update
To install the latest stable version, execute following command:
sudo apt-get install -y mongodb-org
Configure Replica Set:
Edit the MongoDB configuration file to enable replication. Open /etc/mongod.conf with your favorite editor:
sudo nano /etc/mongod.conf
Find (or add) the replication section and set the replica set name (for example, rs0):
replication:
replSetName: rs0
Save the file and exit the editor.
Restart MongoDB:
Restart the service so that the new settings take effect:
sudo systemctl restart mongod.service
Initialize replica set:
mongosh --eval '
rs.initiate({
_id: "rs0",
members: [{ _id: 0, host: "127.0.0.1:27017" }]
})'
Verify:
mongosh --eval 'rs.status()'
You must see PRIMARY.
Why a Replica Set?
Even if you’re running MongoDB on a single server, Rocket.Chat expects a replica set for certain operations (such as handling failover scenarios). This configuration helps ensure reliability and allows you to scale later if needed.
Step 4. Download and Set Up Rocket.Chat
Download Rocket.Chat:
cd /opt
sudo curl -L https://releases.rocket.chat/latest/download -o rocket.chat.tgz
sudo tar -xzf rocket.chat.tgz
sudo mv bundle Rocket.Chat
cd Rocket.Chat
What’s happening here?
- The downloaded bundle contains the compiled Rocket.Chat server code.
- Running npm install downloads all dependencies that Rocket.Chat requires to run.
Install Node dependencies
cd programs/server
npm install
This will take time. If it fails, it’s almost always:
- Wrong Node version
- Low RAM
Step 5. Configure Rocket.Chat as a Systemd Service
Running Rocket.Chat as a systemd service ensures that it starts automatically on boot and restarts in case of failure.
Create a Dedicated User:
For security reasons, it’s best to run Rocket.Chat under its own user account.
cd /opt/Rocket.Chat
sudo useradd -r -m -d /opt/rocketchat -s /bin/bash rocketchat
sudo chown -R rocketchat:rocketchat /opt/Rocket.Chat
Create the Service File:
Open a new service file with your text editor:
sudo nano /etc/systemd/system/rocketchat.service
Paste the following content:
[Unit]
Description=Rocket.Chat Server
After=network.target mongod.service
Requires=mongod.service
[Service]
Type=simple
User=rocketchat
WorkingDirectory=/opt/Rocket.Chat
ExecStart=/usr/bin/node main.js
Restart=always
RestartSec=10
Environment=ROOT_URL=https://chat.example.com
Environment=PORT=3000
Environment=MONGO_URL=mongodb://127.0.0.1:27017/rocketchat?replicaSet=rs0
Environment=MONGO_OPLOG_URL=mongodb://127.0.0.1:27017/local?replicaSet=rs0
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
Key points:
- ExecStart specifies the command to start Rocket.Chat.
- The Environment lines set important variables:
- MONGO_URL points to your MongoDB instance (note the replica set parameter).
- ROOT_URL should be the domain where Rocket.Chat will be accessible—this will be updated once SSL is configured.
- PORT defines which port Rocket.Chat will listen on (default is 3000).
Enable and Start the Service:
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable rocketchat
sudo systemctl start rocketchat
Explanation:
- daemon-reload makes systemd aware of the new service.
- enable ensures Rocket.Chat starts at boot.
- start launches the service immediately.
Check Service Status:
Verify that Rocket.Chat is running:
sudo systemctl status rocketchat
Step 6. Configure Firewall
If UFW (Uncomplicated Firewall) is active, ensure HTTP and HTTPS traffic is allowed:
sudo ufw allow 'Nginx Full'
Step 7. Set Up Nginx as a Reverse Proxy
Using Nginx in front of Rocket.Chat offers several advantages: it handles incoming web traffic, provides load balancing if needed, and enables SSL termination.
Install Nginx:
sudo apt install -y nginx
Create an Nginx Configuration File:
Create a new file for Rocket.Chat. Replace chat.example.com with your actual domain name.
sudo nano /etc/nginx/sites-available/rocketchat
Paste the following configuration:
server {
listen 80;
server_name deb1.hnxcloud.com;
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 $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Explanation of Key Directives:
- listen 80; tells Nginx to listen on HTTP port 80.
- server_name specifies which domain names this configuration applies to.
- proxy_pass forwards incoming traffic to Rocket.Chat running on localhost:3000.
- The proxy_set_header directives ensure that WebSocket connections (used by Rocket.Chat) and client information are properly forwarded.
Enable the Nginx Site:
Create a symbolic link to activate the configuration.
sudo ln -s /etc/nginx/sites-available/rocketchat /etc/nginx/sites-enabled/
Test and Reload Nginx:
Always test the configuration before reloading:
sudo nginx -t
sudo systemctl reload nginx
At this point, if you visit http://chat.yourdomain.com in your browser, you should see Rocket.Chat running. However, this is over HTTP, and we need to secure the connection.
Step 8. Secure Your Rocket.Chat Instance with SSL
Using SSL not only encrypts traffic but also builds trust with your users. Let’s Encrypt offers free SSL certificates that can be automatically renewed.
Install Certbot and the Nginx Plugin:
sudo apt install -y certbot python3-certbot-nginx
Run Certbot to Obtain and Install a Certificate:
Replace chat.yourdomain.com with your actual domain.
sudo certbot --nginx -d chat.example.com
What to expect:
- Certbot will automatically detect your Nginx configuration.
- It will ask for an email address (for renewal notices) and require you to agree to the terms of service.
- Finally, it will ask if you want to redirect HTTP traffic to HTTPS. It’s best to choose the redirect option so that all traffic is secure.
Automatic Renewal:
Let’s Encrypt certificates are valid for 90 days, but Certbot installs a cron job or systemd timer to handle renewal automatically. You can test the renewal process with:
sudo certbot renew --dry-run
Why SSL?
SSL encrypts data in transit between your users and the server, which is critical for protecting sensitive conversations and ensuring privacy.
Step 9. Final Testing and Troubleshooting
Access the Web Interface:
Open your browser and navigate to https://chat.yourdomain.com. You should see the Rocket.Chat setup screen.

Check Logs:
If anything isn’t working as expected, review Rocket.Chat’s logs:
sudo journalctl -u rocketchat
And check Nginx’s error logs:
sudo tail -f /var/log/nginx/error.log
DNS Considerations:
Ensure your domain (chat.example.com.com) points to your server’s IP address. DNS propagation can sometimes take a few minutes to hours.
Conclusion
This detailed tutorial should equip you with a strong understanding of how to install and secure Rocket.Chat on an Debian 13 server. By following these steps, you gain full control over your messaging solution, offering an open-source, privacy-focused alternative to services like Slack. Enjoy your new self-hosted chat server!
