Self-hosting RustDesk means your remote sessions meet on a server you control — not on the project's public infrastructure. It is a one-evening project on a small VPS or a spare office PC, and this guide covers the working core of it: the two server programs, the firewall ports, and the key your clients need.
A RustDesk server is two small programs. hbbs is the ID (rendezvous) server — devices register there and find each other. hbbr is the relay — when two PCs cannot connect directly through their routers, the session passes through hbbr instead. The official Docker method below is the route the RustDesk documentation recommends for most Linux servers, and the same pair can run on a Windows office PC with the project's Windows server installer if a VPS is not your style.
👆 The documented RustDesk Server port set from the official docs — 21116 must be open on both TCP and UDP; the web-client ports are optional.
ufw) both need the ports belowHonest scope note: this guide sets up the free open-source server. RustDesk also offers a Pro server with a web console and account management — nice for larger teams, not needed for the setup below to work.
From RustDesk's official documentation, the server needs:
21115/tcp — NAT type test (hbbs)21116/tcp — TCP hole punching and connection service (hbbs)21116/udp — ID registration and heartbeat (hbbs) — do not skip the UDP half; clients will not register properly without it21117/tcp — relay service (hbbr)21118/tcp and 21119/tcp — only for the web client; leave them closed if you will not use it (the docs specifically advise keeping them closed or behind a reverse proxy)On Ubuntu with ufw, that is a set of commands like sudo ufw allow 21115/tcp, repeated per port — and repeat the same openings in your VPS provider's security group, the step everyone forgets.
Create a folder for the server, and inside it a compose.yml following the official pattern — two services from the rustdesk/rustdesk-server image, both sharing one data folder and both using host networking:
hbbs, volume ./data:/root, network_mode: "host", depending on hbbrhbbr, same volume and host networkingrestart: unless-stopped so they return after a rebootdocker compose up -d and confirm both are running with docker compose psHost networking is required, not a style choice — the server must see the real addresses of connecting clients to arrange direct connections.
cat ./data/id_ed25519.pub and copy the whole line — it ends with =Keep the private key file (id_ed25519, without .pub) backed up and private: it is the identity of your server. Lose the data folder and every client must be re-pointed to a new key.
The full AnyDesk popup video — every step shown live, step-by-step.
▶️ Watch Full VideoYes. RustDesk publishes a Windows server installer that sets up hbbs and hbbr as services with firewall rules. The catch is reachability: an office PC sits behind a router, so you must forward the same ports (21115-21117) on the router and have a public IP or a DDNS name — a VPS avoids both problems.
The two protocols do different jobs on that port: UDP carries ID registration and heartbeat, TCP carries hole punching and the connection service. Opening only TCP is the most common self-host mistake — clients appear to configure fine but never register as Ready.
The open-source server (hbbs and hbbr) is free, including for commercial use. RustDesk Pro adds a web console, user accounts and finer controls for a fee. Most small teams run the free server and never miss the Pro features.