Technical Anshu
Tutorials Blog
🖥️ Self Hosted Server

Self Host Your Own RustDesk Server on a VPS or Office PC

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.

✍️ Technical Anshu🪟 Windows 10 / 11⏱️ 15 minute setup
🎥 Watch the full video — the AnyDesk popup problem and the fix, step-by-step

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.

Terminal — RustDesk server ports and services
$ docker compose ps hbbs running (ID server) hbbr running (relay server) Firewall to open: 21115/tcp hbbs NAT type test 21116/tcp hbbs connection service 21116/udp hbbs ID registration + heartbeat 21117/tcp hbbr relay service 21118/tcp hbbs web client (optional) 21119/tcp hbbr web client (optional)

👆 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.

1

What You Need Before Starting

  1. A small Linux VPS (even the cheapest tier is plenty — the server is lightweight) or an always-on office PC; a VPS is easier because it already has a public IP
  2. Docker and Docker Compose installed on that machine
  3. Access to the firewall — the VPS provider's panel and the OS firewall (such as ufw) both need the ports below
  4. Ideally a domain name pointing at the server, so clients use a name instead of a raw IP that might change

Honest 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.

2

Open the Firewall Ports

From RustDesk's official documentation, the server needs:

  1. 21115/tcp — NAT type test (hbbs)
  2. 21116/tcp — TCP hole punching and connection service (hbbs)
  3. 21116/udp — ID registration and heartbeat (hbbs) — do not skip the UDP half; clients will not register properly without it
  4. 21117/tcp — relay service (hbbr)
  5. 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.

3

Start hbbs and hbbr With Docker Compose

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:

  1. Service hbbs with command hbbs, volume ./data:/root, network_mode: "host", depending on hbbr
  2. Service hbbr with command hbbr, same volume and host networking
  3. Both with restart: unless-stopped so they return after a reboot
  4. Start them with docker compose up -d and confirm both are running with docker compose ps

Host networking is required, not a style choice — the server must see the real addresses of connecting clients to arrange direct connections.

4

Copy the Server Key and Point Clients at It

  1. On first start, hbbs generates its key pair into the data folder. Read the public key with cat ./data/id_ed25519.pub and copy the whole line — it ends with =
  2. On each RustDesk client: open Settings → Network (ID/Relay Server settings) and enter your server's address as the ID Server, paste the public key into the Key field; the Relay field can stay empty — hbbs tells clients the relay address automatically
  3. The client status should turn to Ready — it is now registered on YOUR server
  4. Test a real connection between two clients, including one from outside the office network

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.

📌 Reality check: self-hosting removes the third party, but it makes YOU the third party — updates, uptime and backups of that little server become your job. For two family PCs, the public server is honestly enough; for a support desk, this setup pays for itself in control.

🎥 Watch the Complete Video Guide

The full AnyDesk popup video — every step shown live, step-by-step.

▶️ Watch Full Video
❓ Frequently Asked Questions

Can I run the RustDesk server on a Windows PC instead of a VPS?

Yes. 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.

Why must port 21116 be open on UDP as well as TCP?

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.

Is the self-hosted RustDesk server free for my company?

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.

This guide is based on the Technical Anshu AnyDesk popup video • Stuck on any step? Ask in the video comments — you will get a reply there 🙏