Cloud and Self-Hosting
RustDesk Server Setup: A Comprehensive Guide
By Amjid Ali · · Updated · 4 min read
In this article
- Quick answer: RustDesk server in 5 steps
- How a RustDesk server works
- Requirements
- Step 1: Install Docker
- Step 2: Run hbbs and hbbr with Docker Compose
- Step 3: Open the firewall ports
- Step 4: Get the public key
- Step 5: Configure RustDesk clients
- Option: Debian packages instead of Docker
- Option: the community install script
- Update the server
- Troubleshooting
- RustDesk OSS vs Pro
- Related guides
Prefer to watch? This video walks through it step by step. Prefer to read? The full guide is below.
To set up a RustDesk server, run the two open source services, hbbs (ID/rendezvous server) and hbbr (relay server), on a Linux host with Docker, open TCP 21115-21117 and UDP 21116, and copy the public key from data/id_ed25519.pub into every RustDesk client together with your server's address. On a small VPS this takes about 10 minutes, and from then on your remote sessions are brokered by your own server instead of RustDesk's public ones.
This guide was updated in October 2026 for RustDesk Server OSS 1.1.16 (released July 2026). The first version of this post used a community install script; that is still covered below, but Docker is now the method RustDesk itself recommends.
Quick answer: RustDesk server in 5 steps
- Get a Linux server (a 1 vCPU, 1 GB VPS or a Raspberry Pi is enough) with a public IP or a DNS name such as
rustdesk.example.com. - Install Docker:
bash <(wget -qO- https://get.docker.com). - Download and start the official compose file:
wget rustdesk.com/oss.yml -O compose.yml && sudo docker compose up -d. - Open TCP 21115, 21116, 21117 and UDP 21116 in the server firewall and any cloud security group.
- In each client go to Settings > Network > ID/Relay server, enter the server address and the contents of
data/id_ed25519.pubas the Key.
How a RustDesk server works
| Service | Role | Ports |
|---|---|---|
hbbs |
ID registration, heartbeat, NAT type test and hole punching, so two clients can connect directly | TCP 21115, TCP/UDP 21116, TCP 21118 (web client) |
hbbr |
Relays the session when a direct peer-to-peer connection fails | TCP 21117, TCP 21119 (web client) |
Your session is end-to-end encrypted with the server's key. When a direct connection works, the video stream does not pass through your server at all. RustDesk's docs put relay traffic at roughly 30 KB/s to 3 MB/s per 1080p session (around 100 KB/s for office work), so bandwidth matters more than CPU.
Requirements
- A Linux server: Ubuntu 24.04, Debian 12/13 or similar. RustDesk says the smallest cloud server is enough; a Raspberry Pi also works.
- A static public IP, or a DNS A record pointing at it (recommended, so you can move servers later without reconfiguring clients).
- Root or
sudoaccess.
If you host on Oracle Cloud, remember its security list and the Ubuntu image's iptables both block ports by default; my Oracle Cloud ports fix shows both places.
Step 1: Install Docker
RustDesk's docs use Docker's convenience script:
bash <(wget -qO- https://get.docker.com)
docker --version
docker compose version
If you prefer the apt repository method, follow Docker's Ubuntu instructions. New to Docker? See my Docker beginner's guide.
Step 2: Run hbbs and hbbr with Docker Compose
mkdir -p ~/rustdesk && cd ~/rustdesk
wget rustdesk.com/oss.yml -O compose.yml
cat compose.yml
The file contains this (shown here so you can create it by hand if you prefer):
services:
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-stopped
network_mode: "host" matters: it lets hbbs see each client's real IP instead of Docker's 172.17.0.1, which hole punching needs. Host networking only works on Linux, and with it you do not need ports: mappings.
Start it:
sudo docker compose up -d
sudo docker compose ps
sudo docker logs hbbs
Both containers should be Up. The hbbs log shows the key being generated on first start and the ports it listens on.
Prefer docker run?
sudo docker run --name hbbs -v ./data:/root -td --net=host --restart unless-stopped rustdesk/rustdesk-server hbbs
sudo docker run --name hbbr -v ./data:/root -td --net=host --restart unless-stopped rustdesk/rustdesk-server hbbr
Step 3: Open the firewall ports
| Protocol | Port | Purpose | Open to the internet? |
|---|---|---|---|
| TCP | 21115 | NAT type test | Yes |
| TCP | 21116 | ID registration and hole punching | Yes |
| UDP | 21116 | ID registration and heartbeat | Yes |
| TCP | 21117 | Relay | Yes |
| TCP | 21118, 21119 | Web client (WebSocket) | Only behind a reverse proxy |
| TCP | 21114 | Web console and API | Pro only |
With UFW, allow SSH first so you do not lock yourself out:
sudo ufw allow OpenSSH
sudo ufw allow 21115:21117/tcp
sudo ufw allow 21116/udp
sudo ufw enable
sudo ufw status
On AWS, Azure, Google Cloud, Oracle or DigitalOcean also add the same rules to the provider's security group or cloud firewall. If your server sits at home behind pfSense, create port forwards for the same ports to the server's LAN IP.
Check from another machine that the ports answer:
nc -zv rustdesk.example.com 21116
nc -zv rustdesk.example.com 21117
Step 4: Get the public key
cat ~/rustdesk/data/id_ed25519.pub
It is one line of about 44 characters ending in =. Copy all of it. Never share id_ed25519 (without .pub): that is the private key. Back up both files; if they are lost, hbbs creates a new pair and every client needs the new key.
Step 5: Configure RustDesk clients
On each computer (the one you control from and the one being controlled):
- Open RustDesk and click the menu next to your ID, then Network (in newer clients: Settings > Network). Unlock with admin rights if asked.
- Click ID/Relay server.
- ID server:
rustdesk.example.com(or the IP). - Relay server: leave empty; the client works it out from the ID server. Set it only if hbbr runs on another host.
- API server: leave empty (Pro only).
- Key: paste the contents of
id_ed25519.pub. - Click OK. The status at the bottom should change to Ready.
To roll the same settings out to many PCs, copy the config string from Settings > Network on a configured client and apply it on others:
rustdesk.exe --config <config-string>
Option: Debian packages instead of Docker
Download the rustdesk-server-hbbs and rustdesk-server-hbbr .deb files for your architecture from the GitHub releases page, then:
sudo apt install -y ./rustdesk-server-hbbr_*_amd64.deb ./rustdesk-server-hbbs_*_amd64.deb
sudo systemctl status rustdesk-hbbs rustdesk-hbbr --no-pager
cat /var/lib/rustdesk-server/id_ed25519.pub
Option: the community install script
The original method in this post was the community script by Techahold (formerly dinger1986), which installs hbbs and hbbr as systemd services and publishes ready-made client install scripts on a password-protected web page on port 8000. RustDesk's docs still link to it:
wget https://raw.githubusercontent.com/techahold/rustdeskinstall/master/install.sh
chmod +x install.sh
./install.sh
It prints the server address and key at the end. If you use it, also open TCP 8000 for the download page, and restart the services with:
sudo systemctl restart rustdesksignal
sudo systemctl restart rustdeskrelay
The generated Windows script is unsigned, so PowerShell blocks it by default. Allow it for the current session only rather than changing the machine policy:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Update the server
cd ~/rustdesk
sudo docker compose pull
sudo docker compose up -d
The key lives in ./data, so it survives updates.
Troubleshooting
Client shows "Not ready. Please check your connection": the client cannot reach hbbs. Check the ID server spelling, that TCP and UDP 21116 are open (cloud firewall too) and that docker compose ps shows hbbs running.
"Key mismatch": the Key field does not match the server. Paste id_ed25519.pub again on both sides, with no spaces or line breaks.
Connects but always relayed or slow: direct connections need hole punching. Make sure hbbs uses network_mode: "host", and that UDP 21116 is open. Some carrier-grade NAT and strict corporate networks will always fall back to the relay on 21117.
"Connection error: Timeout": 21117 (relay) is blocked, or hbbr is down. Test with nc -zv <server> 21117.
Clients still use the public servers: the ID server field is empty on one side. Both computers need your server settings.
RustDesk OSS vs Pro
| Server OSS | Server Pro | |
|---|---|---|
| Price | Free (AGPL-3.0) | Annual licence, RustDesk lists from USD 11.88/month billed yearly (1 user, 20 devices) |
| hbbs and hbbr | Yes | Yes |
| Web console, user login, address book | No | Yes |
| 2FA, audit log, access control | No | Yes |
| OIDC (SSO) and LDAP | No | Basic plan and up |
| Custom branded client generator | No | Basic plan and up |
| Support | Community (Discord, GitHub) |
For a homelab or helping family, OSS is all you need. Pro starts to pay off when you support many users and want accounts, audit trails and a preconfigured custom client instead of typing the key on every machine.
Related guides
- AnyViewer remote desktop review for a hosted alternative.
- Docker for beginners.
- pfSense vs OPNsense if you are choosing a firewall for port forwarding at home.
Frequently asked questions
How do I set up my own RustDesk server?+
Install Docker on a Linux server, download the official compose file with wget rustdesk.com/oss.yml -O compose.yml, and run sudo docker compose up -d. That starts hbbs (the ID server) and hbbr (the relay). Open TCP 21115-21117 and TCP/UDP 21116, copy the public key from data/id_ed25519.pub, and enter the server address and key under Settings > Network in each RustDesk client.
What ports does a RustDesk server need?+
The minimum is TCP 21115 (NAT type test), TCP and UDP 21116 (ID registration and hole punching) and TCP 21117 (relay). TCP 21118 and 21119 are only for the web client and should stay closed unless you put them behind a reverse proxy. TCP 21114 is the web console and API, which only RustDesk Server Pro uses.
Where is the RustDesk server key?+
hbbs creates a key pair on its first start in its data folder. With the official Docker setup that is ./data/id_ed25519.pub next to your compose file; with the Debian packages it is in /var/lib/rustdesk-server/. Share only the .pub file; keep id_ed25519 private, because anyone with it can impersonate your server.
What is the difference between hbbs and hbbr?+
hbbs is the ID and rendezvous server: clients register their ID with it and it helps two clients find each other and punch through NAT for a direct connection. hbbr is the relay server: when a direct connection is not possible, the session traffic is relayed through it on port 21117.
Is RustDesk Server free?+
RustDesk Server OSS (hbbs and hbbr) is free and open source under AGPL-3.0 with no device limit. RustDesk Server Pro is a paid, annual licence that adds a web console, user accounts, address books, 2FA, audit logs, access control, OIDC and LDAP, and a custom client generator. RustDesk lists Pro from USD 11.88 a month, billed yearly.
Why does RustDesk say Key mismatch?+
The key entered in the client does not match the public key of the server it is connecting to. Copy the full contents of id_ed25519.pub again, with no spaces or line breaks, into the Key field on both computers. If you deleted the data folder, hbbs generated a new key and every client needs the new one.
Sources
- Self-host overview and required ports, RustDesk documentation
- RustDesk Server OSS: Docker, RustDesk documentation
- RustDesk Server OSS: Installation, RustDesk documentation
- Client configuration, RustDesk documentation
- rustdesk-server releases, GitHub (RustDesk)
- RustDesk pricing, RustDesk
Keep reading
Cloud and Self-HostingHow to Deploy a Flexible VPS for Apps: Kamatera ReviewNeed to deploy a flexible VPS for apps without committing to a fixed server shape? This Kamatera review examines its configurable cloud servers, scaling options, trial… · 8 min read
Cloud and Self-HostingExchange Server to Microsoft 365 Migration: A Pre-Migration Readiness ChecklistWhat to check before moving Exchange Server mailboxes to Microsoft 365: environment, migration method, identity, mail flow, permissions, security, pilot and cutover. · 7 min read
Cloud and Self-HostingList of Best Server Virtualization Software in ItalyA list of the best server virtualization software options for enterprises in Italy, compared on architecture, licensing, and security. · 5 min read