On this page
- What do the two RustDesk server programs do?
- What should be ready on the server?
- How do you start hbbs and hbbr with Docker Compose?
- Which ports must be open, and how?
- How do clients connect to your server?
- Does the RustDesk server need a reverse proxy or HTTPS?
- How do you back up and update the server?
- Why do connections fail or always go through the relay?
- Questions
What do the two RustDesk server programs do?
The open-source server has two parts. hbbs keeps a registry of client IDs and helps two machines find each other and attempt a direct connection. hbbr relays the session when a direct connection is not possible, for example when both sides sit behind strict NAT. Neither stores screens or files; sessions are encrypted between the clients.
Both are small. A 1 GB plan handles a team easily; what grows with use is relayed traffic, which counts toward the monthly transfer of the plan (2 TB on A1-1). Choose a city close to the people you support to keep latency low; see cities.
What should be ready on the server?
- Ubuntu 24.04/22.04, Debian 12/13, Rocky Linux 9 or AlmaLinux 9 with a sudo user.
- Docker Engine and the Compose plugin: see Docker Engine, or deploy the Docker app image.
- Optionally a hostname such as
rd.example.netpointing to198.51.100.24. The IP address also works, but a name lets you move the server without reconfiguring every client.
How do you start hbbs and hbbr with Docker Compose?
Create a folder and a Compose file. Host networking avoids port mapping and lets the servers see the real client addresses they need for hole punching.
sudo mkdir -p /opt/rustdesk && sudo chown deploy:deploy /opt/rustdesk
cd /opt/rustdesk
nano compose.yamlservices:
hbbs:
container_name: hbbs
image: rustdesk/rustdesk-server:latest
command: hbbs
volumes:
- ./data:/root
network_mode: host
depends_on:
- hbbr
restart: unless-stopped
hbbr:
container_name: hbbr
image: rustdesk/rustdesk-server:latest
command: hbbr
volumes:
- ./data:/root
network_mode: host
restart: unless-stoppeddocker compose up -d
docker compose logs --tail 20On first start hbbs generates a key pair in ./data: id_ed25519 (private, keep it secret) and id_ed25519.pub.
Which ports must be open, and how?
RustDesk uses TCP 21115 (NAT test), TCP and UDP 21116 (ID registration, heartbeat and hole punching) and TCP 21117 (relay). Because the containers use host networking, the normal OS firewall applies to them. On Ubuntu and Debian:
sudo ufw allow OpenSSH
sudo ufw allow 21115:21117/tcp
sudo ufw allow 21116/udp
sudo ufw enable
sudo ufw statusOn Rocky Linux and AlmaLinux:
sudo firewall-cmd --permanent --add-port=21115-21117/tcp --add-port=21116/udp
sudo firewall-cmd --reload
sudo firewall-cmd --list-portsConfirm the listeners with sudo ss -tulpn | grep 2111. Ports 21118 and 21119 are only for the web client and can stay closed. More detail on rules lives in ufw and firewalld.
How do clients connect to your server?
Print the public key and keep it at hand:
cat /opt/rustdesk/data/id_ed25519.pubIn each RustDesk client open Settings, Network, then ID/Relay server. Enter rd.example.net as the ID server, the same host as the relay server, and paste the key into the Key field. Leave the API server empty; it belongs to the paid server edition. Both the controlling and the controlled machine must use the same settings. Once applied, the status line at the bottom of the client window should show that it is ready.
Current server releases accept only clients that present the matching key, so strangers cannot use your relay just by knowing the address.
Does the RustDesk server need a reverse proxy or HTTPS?
No. The open-source server has no web interface, and its traffic is not HTTP, so Nginx or Caddy have nothing to add for ports 21115 to 21117. Security comes from the key pair: clients verify the server key, and sessions are encrypted end to end. What you should protect is the private key file in ./data; anyone with it can impersonate your server.
If you want a friendly download page for your team with the hostname and key, a small static page served by Caddy on https://rd.example.net works well; see Caddy HTTPS.
How do you back up and update the server?
The only state worth saving is the key pair. If you lose it, every client must be reconfigured with a new key.
sudo tar czf ~/rustdesk-keys-$(date +%F).tar.gz -C /opt/rustdesk data/id_ed25519 data/id_ed25519.pubStore that archive somewhere safe off the server. To update:
cd /opt/rustdesk
docker compose pull
docker compose up -d
docker image prune -fClients and server do not have to share an exact version, but keeping both reasonably current avoids protocol surprises.
Why do connections fail or always go through the relay?
- Client shows "not ready": check that UDP 21116 is open; the heartbeat uses it.
- Key mismatch error: the client key does not match
id_ed25519.pub, often due to a missing character when pasting. - Everything relays: one side is behind strict NAT; this is expected and still works, just using more transfer. Check traffic with vnstat.
- Logs:
docker compose logs -f hbbsshows registrations and punch attempts.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about RustDesk relay server
Can I install RustDesk server without Docker?
Yes. The project publishes Debian packages for hbbs and hbbr, plus plain binaries you can run from systemd units. Docker is used here because the same steps work on every listed distribution.
Do I need two servers for hbbs and hbbr?
No. Both run comfortably on one small VPS, which is the usual setup.
Does relayed traffic use much bandwidth?
It depends on screen resolution and session time. Direct connections do not touch the server after setup; relayed sessions pass every frame through it, so watch usage if many sessions relay.
Can I change the key later?
You can delete the key files and restart to generate a new pair, but every client then needs the new public key. Treat the key as long-lived.
Is the RustDesk server the same as the desktop app?
No. The server only brokers and relays connections. The controlled and controlling computers each run the RustDesk desktop or mobile client.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- GitLab Community Edition
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- n8n workflow automation
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Mattermost team chat
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- HashiCorp Vault secrets server
- OpenBao secrets management
- Infisical secrets manager
- Authelia SSO and forward auth
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Metabase dashboards
- Appwrite backend server
- Self-hosted Supabase
- PocketBase backend
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- AFFiNE workspace
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- NetBox network inventory
- UVdesk help desk
- YetiForce CRM