Self-host a RustDesk server
A self-hosted RustDesk server is two small programs: hbbs, the ID and rendezvous server, and hbbr, the relay. Run both from the official Docker image on Ubuntu 24.04, open TCP 21115~21119 and UDP 21116, and paste the server address and public key into every client. A small plan such as P1 (1 vCPU, 1 GB RAM, 20 GB NVMe) is enough, because most sessions connect directly and only some pass through the relay.
Self-hosted apps guide, updated 2026-12-03
What does a RustDesk server actually do?
RustDesk is an open source remote desktop tool. Every client registers with an ID server (hbbs) so other clients can find it by its ID. When you connect, hbbs helps both sides try a direct peer to peer connection through their routers. If that works, the screen data flows directly between the two computers and never touches your server. If it fails, typically because of strict corporate or mobile networks, the session goes through the relay server (hbbr), which forwards the encrypted stream.
Running your own pair means your devices do not depend on public servers, the relay sits in a city you choose, and only clients that know your key can use it. RustDesk is not a console app image, so you install it by hand; the Docker CE image is the quickest base, and plain Ubuntu 24.04 works after installing Docker.
Which plan and city should you choose?
hbbs and hbbr together use very little memory and CPU; the relay mostly copies bytes. What grows with use is outgoing traffic for relayed sessions.
- P1 (1 vCPU, 1 GB RAM, 20 GB NVMe, $3.95 a month): a person or small team, any of the 15 cities.
- S4 (2 vCPU, 4 GB RAM, 40 GB NVMe): Europe only, more headroom if the same server also runs other tools.
- P2 (1 vCPU, 2 GB RAM, 40 GB NVMe): a support desk with many relayed sessions at the same time.
Choose a city close to the people who connect most, since relayed sessions travel client, relay, client. A support team in the UK helping customers in Europe fits London; an office in Australia fits Sydney. The ID server only exchanges small messages, so its location matters less.
Which DNS record should point at the server?
Clients can use the bare IP address, but a name is easier to move later. Create an A record such as rd.example.com pointing at 203.0.113.10 at your DNS provider, and optionally an AAAA record for the IPv6 address. If you ever replace the server, you only change the record, and clients keep working once it has propagated, provided you copy the key files as well (see below). The DNS guide shows the steps.
How do you run hbbs and hbbr with Docker Compose?
Create a folder and a compose file:
mkdir -p /opt/rustdesk/data
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-stoppedHost networking lets hbbs see the real client addresses, which hole punching needs. Start it:
docker compose up -d
docker compose logs --tail 20The log of hbbs shows the ports it listens on and the key it loaded. ss -tulpn | grep 2111 should list TCP 21115, 21116, 21117, 21118, 21119 and UDP 21116.
Without Docker, the project also publishes .deb packages and plain binaries for amd64 and arm64 that install hbbs and hbbr as systemd services; the ports and key file are the same.
Which ports must be open, and what does each one do?
| Port | Protocol | Used by |
|---|---|---|
| 21115 | TCP | hbbs, NAT type test |
| 21116 | TCP and UDP | hbbs, ID registration, heartbeat and hole punching |
| 21117 | TCP | hbbr, relay |
| 21118 | TCP | hbbs, WebSocket for the web client |
| 21119 | TCP | hbbr, WebSocket relay for the web client |
ufw allow OpenSSH
ufw allow 21115:21119/tcp
ufw allow 21116/udp
ufw enableIf you never use the browser client, you may leave 21118 and 21119 closed. Forgetting UDP 21116 is the classic mistake: clients appear online but connections are slow or always relayed. With host networking Docker does not add its own rules, so ufw is in charge; the firewall guide has the details.
Where is the key file, and why does it matter?
On first start hbbs creates a key pair in the data folder:
ls /opt/rustdesk/data
cat /opt/rustdesk/data/id_ed25519.pubThe public key (id_ed25519.pub) is the string you give to clients. It lets them verify they are talking to your server, and current server releases refuse clients that do not present it, so strangers who guess your address cannot use your relay. If an older guide tells you to add -k _ to the commands, that was how older releases enforced the key; check the release notes of your version.
The private key (id_ed25519) must stay secret and must be kept: if you rebuild the server and lose it, hbbs makes a new pair and every client has to be updated. Copy both files somewhere safe right after the first start.
How do you configure the RustDesk clients?
On each computer open RustDesk, go to Settings, Network, and unlock the ID/Relay server section. Enter:
- ID server:
rd.example.com - Relay server:
rd.example.com(optional; it defaults to the same host) - Key: the full content of
id_ed25519.pub
Leave the API server empty, since the free server has no web API. Apply, and the status line at the bottom of the main window should say the client is ready. Both computers in a session must use the same server and key. For many machines, RustDesk lets you export the settings as a configuration string and import it on others, which avoids typing errors in the key.
How much traffic does the relay use?
Direct peer to peer sessions do not pass through your server at all, so they use none of your allowance. Relayed sessions do: hbbr receives the stream from one side and sends it to the other, so the outgoing amount roughly equals the session data. A remote desktop stream varies a lot with screen size, motion and quality setting; office work with mostly still screens is light, while video playback over remote desktop is heavy.
To count it, install vnstat and look at the monthly outgoing total, as shown in monitoring basics. As a worked example with assumed figures: 10 relayed sessions a day of 30 minutes at an average of 1 Mbit/s gives 10 x 1800 x 1 / 8 = 2,250 MB a day, about 68 GB a month, a small share of the 20 TB that P1 includes in Europe (0.5 TB in North America, 0.5 TB in Asia-Pacific). Extra outgoing traffic costs $0.72 per TB in Europe and North America or $4.98 per TB in Asia-Pacific and Sao Paulo. Incoming traffic is free.
How do you update, back up and troubleshoot the server?
cd /opt/rustdesk
docker compose pull
docker compose up -dThe data folder survives updates, so clients keep working. Your backup is tiny: /opt/rustdesk/data with the two key files and the small database hbbs keeps. Copy it off the server with rsync after setup, or rely on the backup add-on ($0.79 per month on P1) for 7 daily disk copies.
- "Key mismatch": a client has an old or partial key. Paste the full public key again.
- Clients show "Not ready" or connecting forever: TCP 21116 or UDP 21116 is blocked. Check
ufw statusand test from outside withnc -vz rd.example.com 21116. - Connections always relayed and slow: UDP 21116 is closed, or the client network blocks UDP. Opening the port helps; the client network may still force the relay.
- Everything broke after a rebuild: the key pair changed. Restore the saved key files into the data folder and restart.
Questions about this guide
Does the RustDesk server run on Arm?
Yes. The Docker image and the packages are built for arm64 too, so A4 works in Frankfurt, Nuremberg, Helsinki or Amsterdam with the same compose file.
Can the relay see my screen data?
Sessions are end to end encrypted between the two clients; the relay forwards encrypted packets. Running the server yourself also keeps connection metadata on a machine you control.
Do I need hbbr if most sessions are direct?
Yes. Some networks never allow a direct connection, and without a relay those sessions simply fail. hbbr uses almost nothing while idle.
Can I use the IP address instead of a domain?
Yes, 203.0.113.10 works in the client fields. A domain makes moving to another server easier later.
How many devices can one server handle?
The ID server handles many devices on a small plan. The limiting factor is relayed traffic during busy hours, which you can watch with vnstat.
Does the free server include an address book or web console?
No, those belong to a separate paid server edition from the RustDesk project. The free hbbs and hbbr give you ID and relay service, which is all remote sessions need.