Self-Hosting RustDesk: Run Your Own Remote Desktop Server
Set up your own RustDesk ID and relay servers with Docker: full compose file, ports explained, client setup, and the gotchas that trip people up.
Updated
Why Self-Host RustDesk?
RustDesk is a free, open-source remote desktop tool — think TeamViewer or AnyDesk, except you can run the whole backend yourself. By default, RustDesk clients check in with public rendezvous servers and fall back to public relays when a direct connection fails. That works fine, but self-hosting the server takes the middleman out entirely: your machines find each other through your own server, relayed traffic stays on hardware you control, and connections are typically faster and more reliable.
The self-hosted setup is two small services in Docker, and it runs happily on almost anything — a mini PC, a VM, a NAS, or the home server you already leave on 24/7.
The Two Services: hbbs and hbbr
RustDesk Server is split into two pieces:
- hbbs — the ID/rendezvous server. Clients register with it and use it to find each other, exchange connection info, and punch a direct peer-to-peer connection whenever possible.
- hbbr — the relay server. When a direct connection can't get through (strict NAT, firewalls, some hotel and corporate networks), traffic relays through hbbr instead.
Both are tiny. Together they idle at well under 100 MB of RAM, so there's no reason not to run both even if relays turn out to be rare on your network. All session traffic is end-to-end encrypted either way — the relay can pass traffic it cannot read.
What You Need
- Any always-on Linux machine with Docker and Docker Compose
- A static LAN IP (or a DNS name) for that machine, so clients can always find the server
- About five minutes
The Docker Compose Setup
This is a complete working compose file:
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
Two things worth understanding before you start it:
- Host networking is deliberate. The RustDesk server expects to bind its ports directly, and host mode is the configuration the project itself recommends. There are no
ports:mappings because the host network is the container network — control access with the host firewall instead. - The
./datafolder is the important part. On first start, the server generates its key pair there (id_ed25519andid_ed25519.pub). Back that folder up. If you lose it, every client has to be reconfigured.
Start it with docker compose up -d, then check docker compose logs — hbbs prints the public key it's using on startup.
Ports to Know
With host networking, the server listens on these ports:
- 21115/TCP — NAT type test
- 21116/TCP and UDP — ID server: client registration, heartbeat, hole punching (the UDP half matters — don't forward only TCP)
- 21117/TCP — relay server
- 21118/TCP and 21119/TCP — web client support (only needed if you use the browser-based client)
On your home LAN, you don't need to forward any of these on your router. Clients on the LAN — or reaching the LAN through a VPN like Tailscale or WireGuard — connect directly. Only forward ports if you deliberately want the server reachable from the open internet, and understand that you're publishing a login surface when you do.
Point Your Clients at It
On each machine you want to control or connect from:
- Open RustDesk → Settings → Network
- Unlock the network settings
- Set ID server to your server's address, e.g.
192.168.1.10:21116 - Set Relay server to the same machine, e.g.
192.168.1.10:21117 - Paste the contents of
id_ed25519.pubinto the Key field - Apply, and repeat on every client
The key step is the one people skip — and it's why "the server is running but nothing connects." Every client must carry the server's public key, or connections are refused.
Gotchas From a Real Install
- Wayland logins don't work. On Linux machines running a Wayland session, RustDesk can't drive the login screen — you'll connect to a frozen or black display. On Ubuntu with GDM, set
WaylandEnable=falsein/etc/gdm3/custom.confand reboot so the machine falls back to Xorg. Desktops already logged in are less affected; it's the unattended login screen that bites. - A key mismatch fails silently. If one client has an old key (say, after you rebuilt the server and generated a new one), it just won't connect. Re-check the key on both ends before debugging the network.
- The server being "up" isn't the test. The real test is connecting from a different network — tether a laptop to your phone and connect back. That exercises the rendezvous and, if direct connection fails, the relay path.
- Update by recreating. The image uses the
latesttag; pull and recreate the containers periodically. Your./datavolume — and therefore your key and client configs — survives.
The Bottom Line
A self-hosted RustDesk server is one of the best effort-to-payoff projects in a homelab: one small compose file, one key to distribute, and remote access to every machine you own stops depending on anyone else's infrastructure. Run it on the same always-on box as the rest of your services, point your clients at it once, and it quietly does its job for years.