Headscale on a VPS: Self-Host Your Tailscale Control Server
Run Headscale on a VPS to replace Tailscale's coordination server: install, TLS, embedded DERP, ACLs, client setup and the metadata it still can't hide.
Headscale is an open-source replacement for Tailscale's coordination server. You run it on your own VPS and keep using the official Tailscale clients, so your private mesh network no longer depends on a third-party account. The main benefit is control over metadata: which devices you own, their public IPs, and when they come online stay on a server you run instead of with Tailscale Inc. This guide covers installation, TLS, a self-hosted DERP relay, access rules and client enrollment. It also covers what moving the control plane does not change.
What Headscale replaces (and what it doesn't)
A Tailscale network has two layers:
- Data plane. Devices talk to each other over WireGuard, directly where possible and through a DERP relay (Designated Encrypted Relay for Packets) when NAT gets in the way. Traffic is end-to-end encrypted between devices.
- Control plane. The coordination server hands out keys, IP addresses, DNS settings and access rules. It also tells every device where its peers can be reached.
Headscale replaces only the control plane. Clients still build WireGuard tunnels between themselves. The coordination server can never decrypt that traffic. It does see a lot of metadata, though:
- Every node's WireGuard public key and hostname
- Every node's public endpoints (IP and port)
- Which user each node belongs to
- OS details and online/offline status
That metadata is what you are taking back. It is the main reason to self-host.
This is a different job from a full-tunnel VPN that sends all your browsing out through one exit IP. For that, see self-hosted WireGuard VPN on a VPS. Headscale is for connecting your own devices to each other: a laptop, a home server, a phone and a couple of VPSs.
Requirements
- A Linux VPS with a public IPv4 address. Debian 12 or Ubuntu 24.04 is assumed below.
- A domain or subdomain (for example
hs.example.com) with an A record pointing at the VPS. - Open ports: TCP 443 for the control server and embedded DERP, TCP 80 if you use HTTP-01 certificate validation, and UDP 3478 for STUN.
Sizing is not a concern. Headscale is a single Go binary using SQLite, and for a personal or small-team tailnet it typically uses tens of megabytes of RAM. The smallest VPS you can find will run it. The resource that actually matters is bandwidth, and only if many connections end up relayed through your DERP server (covered below).
A note on IPv6: you do not need a public IPv6 address. The tailnet assigns devices internal addresses from 100.64.0.0/10, plus an IPv6 ULA range used only inside the mesh. All of it runs fine over IPv4 transport.
Step 1: Install Headscale
The project publishes .deb packages on its GitHub releases page. Check the releases for the current version and substitute it below:
VERSION=0.26.1 # replace with the current release
wget https://github.com/juanfont/headscale/releases/download/v${VERSION}/headscale_${VERSION}_linux_amd64.deb
sudo apt install ./headscale_${VERSION}_linux_amd64.deb
The package creates a headscale system user, a systemd unit and a default config at /etc/headscale/config.yaml. Don't start the service yet.
Headscale changes config keys and CLI flags between minor releases. Treat the snippets below as a map of what to set. Use the example config shipped with your installed version as the authoritative reference.
Step 2: Configure the server
Edit /etc/headscale/config.yaml. These are the settings that matter:
server_url: https://hs.example.com
listen_addr: 127.0.0.1:8080
metrics_listen_addr: 127.0.0.1:9090
prefixes:
v4: 100.64.0.0/10
v6: fd7a:115c:a1e0::/48
database:
type: sqlite
dns:
magic_dns: true
base_domain: tailnet.internal
nameservers:
global:
- 9.9.9.9
Notes on these choices:
server_urlmust match exactly what clients will connect to, includinghttps://.listen_addron localhost keeps Headscale off the public interface. A reverse proxy in front handles TLS.base_domainmust not be the same as the domain inserver_url. MagicDNS then gives each node a name likelaptop.tailnet.internal.nameservers.globalpushes a DNS resolver to every client. Pick deliberately, since every device will use it.
Step 3: TLS in front of Headscale
The Tailscale protocol upgrades its HTTP connection to a long-lived stream. Your reverse proxy must therefore pass Upgrade and Connection headers through correctly. Caddy handles this without extra configuration and obtains certificates automatically:
hs.example.com {
reverse_proxy 127.0.0.1:8080
}
With nginx, follow the reverse-proxy section of the Headscale docs, which includes the required upgrade headers and timeouts. Misconfigured proxies cause most "client connects, then hangs" reports.
Headscale also has built-in Let's Encrypt support (tls_letsencrypt_hostname) if you'd rather skip the proxy and bind it directly to 443.
Start the service and check it:
sudo systemctl enable --now headscale
sudo systemctl status headscale
journalctl -u headscale -n 50
Step 4: Run your own DERP relay
By default, Headscale points clients at Tailscale's public DERP servers. Your relayed traffic stays encrypted, but Tailscale's relays still see which IPs connect and how much they send. If the point of the exercise is keeping metadata off third-party infrastructure, enable the embedded DERP server and drop the default map:
derp:
server:
enabled: true
region_id: 999
region_code: "own"
region_name: "Own DERP"
stun_listen_addr: "0.0.0.0:3478"
ipv4: 203.0.113.10 # your VPS public IPv4
urls: [] # stop using Tailscale's public DERP map
auto_update_enabled: false
The trade-off. With a single region, any device pair that can't connect directly relays through your one VPS. If that server is down or far away, relayed connections suffer, and you have no fallback.
Bandwidth. Relayed traffic counts against your monthly transfer. Most home and mobile networks manage direct connections, so relaying is usually the exception rather than the rule. Check after a week of real use to see which case you're in.
Open the ports. In an nftables input chain:
tcp dport { 80, 443 } accept
udp dport 3478 accept
Restart Headscale after editing the config.
Step 5: Users, keys and enrolling devices
Create a user, then a short-lived pre-auth key:
sudo headscale users create alice
sudo headscale users list
sudo headscale preauthkeys create --user alice --expiration 1h
Recent releases may expect the numeric user ID rather than the name for --user. Check headscale preauthkeys create --help on your version.
On each client, install the official Tailscale client and point it at your server:
sudo tailscale up --login-server https://hs.example.com --authkey <KEY>
The Android and iOS apps let you set a custom coordination server. Where that option lives varies between app versions.
Disable client log uploads. The Tailscale client sends diagnostic logs to Tailscale's log service by default, which partly defeats self-hosting. On Linux, add --no-logs-no-support to the tailscaled flags, typically through FLAGS= in /etc/default/tailscaled, then restart tailscaled. Check the client documentation for the equivalent on other platforms.
Step 6: Access rules
Without a policy, every node can reach every other node. That is fine for a single person and risky once a shared server or a second user joins.
Point policy.path in the config at a HuJSON file:
{
"groups": {
"group:admins": ["alice@"]
},
"tagOwners": {
"tag:server": ["group:admins"]
},
"acls": [
{ "action": "accept", "src": ["group:admins"], "dst": ["*:*"] },
{ "action": "accept", "src": ["tag:server"], "dst": ["tag:server:5432"] }
]
}
Newer Headscale versions require the trailing @ on user names in policies; older ones don't. A broken policy can stop the server from starting, so check the logs after every change.
A useful pattern: once the tailnet works, expose SSH on your servers only on the tailnet interface and close port 22 to the internet. The reasoning is in SSH hardening on a VPS. Keep your provider's console access working first so a mistake doesn't lock you out.
Verification
Run these after setup:
sudo headscale nodes list # every enrolled device, with its 100.x address
tailscale status # on a client: peers and their state
tailscale ping <peer> # shows "via DERP(own)" or a direct endpoint
tailscale netcheck # should list only your DERP region
Two results confirm the privacy goal. First, netcheck should show no Tailscale-operated regions. Second, tailscale ping should show direct connections for most device pairs. If everything goes via DERP, check that UDP isn't blocked on the client networks.
Troubleshooting
- Client hangs at login. Usually the reverse proxy isn't passing the connection upgrade, or
server_urldoesn't match the URL the client uses. - Everything relays, nothing direct. UDP 3478 is closed on the VPS, or a client sits behind strict NAT. Some networks always need relaying.
- Headscale won't start after an upgrade. A config key was renamed. Compare your file against the new example config and read the release notes before upgrading.
What self-hosting the control plane does not hide
Be clear about where the metadata ends up:
- Your VPS stores it. The Headscale database on your VPS now holds device names, keys and endpoints. Whoever controls that server controls your tailnet. A control server can add a node to your network, so compromising the VPS is a real risk, not just a privacy issue. Headscale does not implement every Tailscale feature, and its feature list documents what is missing. Keep the server patched and minimal.
- Your provider can see the disk. A hosting provider has technical access to unencrypted storage. See what your VPS provider can actually see.
- Endpoint IPs are still exposed. Direct WireGuard connections expose each device's public IP to its peers, and every device's IP to the control server. If you enroll your home machine, its home IP is in that database.
- Back up the database. Back up
/var/lib/headscaleencrypted and off-server. Losing it means re-enrolling every device.
For a home server behind CGNAT that only needs to be reachable from the internet, a plain tunnel may be simpler than a full mesh. The CGNAT tunneling guide covers that setup.
Where a VPS fits
Headscale runs comfortably on the smallest VPS plan. What matters more is who knows the server is yours. IronBalkans offers full-root KVM VPS in Romania with no-KYC accounts and payment in Monero, Bitcoin or Litecoin. That keeps the machine coordinating your private network from being tied to a name or card. If that matters for your setup, a small plan is enough to start.
