How to Install Headscale on a VPS as a Self-Hosted Tailscale Control Plane

When the brain of your mesh network should live on your own server
Managing several servers tends to produce the same pattern: a laptop needs the admin panel on a VPS, another VPS needs backups from an office NAS, and a phone needs a dashboard that must never face the public internet. Each connection can be solved by opening a port, but every shortcut adds another gap to check.
Tailscale tidies that mess up. Your devices form a private mesh, each gets an address from 100.64.0.0/10, and they connect directly over WireGuard whenever possible. What often goes unmentioned is the coordination server behind it, the component that introduces devices to each other, hands out keys, and decides who may reach whom. In normal use, that role belongs to Tailscale's cloud service; Headscale moves it onto your own server.
Once the control plane runs on your VPS, metadata about which devices are online and how access policy is arranged no longer passes through a third party's infrastructure, and you are not bound by account plan limits. In return, updates, backups, TLS certificates, and access policy become your responsibility.
This guide focuses squarely there: installing Headscale as the control server, not repeating a basic Tailscale tutorial. You will install the official package, configure the server address and internal DNS, register a first node with a pre-auth key, prove two nodes can reach each other, then lock access down with a file-based policy.
One limitation is worth stating up front: Headscale implements a single tailnet, and the project openly says performance is not its top priority compared with behavioral correctness. For a homelab or small team, that suffices.
Update, 13 November 2026: Headscale 0.29.7 (released 30 October 2026) is a security release — if you are installing from this guide, use 0.29.7 as in Step 1. The minimum supported Tailscale client is v1.80.0; version 1.104.4 or newer is recommended, especially if you use Tailscale SSH. When upgrading, move one minor version at a time and always take the latest patch of that minor — never skip a minor.
Prerequisites
Prepare a VPS running Ubuntu 22.04 or newer, or Debian 12 or newer, with sudo access and SSH key login already working.
You also need a domain or subdomain pointing at the VPS, for example headscale.example.com. This becomes server_url, the address every Tailscale client uses to find your control server; replace every occurrence of the example domain with your own. Without correct DNS, TLS issuance and node registration fail with confusing messages.
On the firewall side, open TCP 443 for Headscale and keep the metrics port 9090 closed to the internet. Set aside two devices for testing.
Finally, Headscale must not run on a machine that is also a node in the same tailnet; the project's docs say that combination is unsupported, partly because it can interfere with subnet routers, relays, and MagicDNS.
Step 1: Download and install the official .deb package
Headscale publishes container images, but its FAQ states Docker deployment is not officially supported. The recommended path for Debian and Ubuntu is the .deb package from the project's GitHub releases page, which sets up a dedicated system user, a default configuration, and a systemd unit.
Open the juanfont/headscale releases page and note the latest stable version. The commands download the amd64 package; replace HEADSCALE_VERSION with the version you noted, without the v prefix, and HEADSCALE_ARCH if your server uses a different architecture:
HEADSCALE_VERSION="0.29.7"
HEADSCALE_ARCH="amd64"
wget --output-document=headscale.deb \
"https://github.com/juanfont/headscale/releases/download/v${HEADSCALE_VERSION}/headscale_${HEADSCALE_VERSION}_linux_${HEADSCALE_ARCH}.deb"
Check the download is a Debian package:
ls -lh headscale.deb file headscale.deb
The expected result mentions Debian binary package. If you get an HTML document or a tiny file instead, the version or architecture is probably wrong.
Install the package:
sudo apt install ./headscale.deb
headscale version id headscale
The expected result is the downloaded version and a headscale system user line.
Step 2: Write the server configuration in /etc/headscale/config.yaml
The .deb package puts the configuration at /etc/headscale/config.yaml, and an example ships at /usr/share/doc/headscale/examples/config-example.yaml. Back up the default first:
sudo cp /etc/headscale/config.yaml /etc/headscale/config.yaml.bak
Open the file in your editor:
sudo nano /etc/headscale/config.yaml
A few keys deserve attention, because a one-line mistake here looks exactly like a network problem. First, server_url must hold the public address clients use, including the https scheme:
server_url: https://headscale.example.com
Second, set the listen address. The default binds Headscale to 127.0.0.1:8080, which outside clients cannot reach. Since this guide uses Headscale's built-in Let's Encrypt support with a TLS-ALPN-01 challenge, listen on port 443:
listen_addr: 0.0.0.0:443
Third, fill in the built-in TLS section. Headscale can request and renew its own certificate:
acme_url: https://acme-v02.api.letsencrypt.org/directory acme_email: "" tls_letsencrypt_hostname: headscale.example.com tls_letsencrypt_cache_dir: /var/lib/headscale/cache tls_letsencrypt_challenge_type: TLS-ALPN-01
Put a monitored address in acme_email, since it receives certificate-related notices. The tls_letsencrypt_hostname value must match the domain in server_url, with no scheme and no port.
Fourth, leave node address allocation at its defaults; narrowing the range without understanding the consequences can produce odd client behavior:
prefixes: v4: 100.64.0.0/10 v6: fd7a:115c:a1e0::/48
Fifth, set the database to SQLite. The project FAQ recommends it for every Headscale use case, and says PostgreSQL is kept only for legacy reasons:
database:
type: sqlite
sqlite:
path: /var/lib/headscale/db.sqlite
write_ahead_log: true
Sixth, enable MagicDNS with a base domain different from the server domain, so devices can be called by names like laptop.tail.example.com:
dns:
magic_dns: true
base_domain: tail.example.com
nameservers:
global:
- 1.1.1.1
- 1.0.0.1
Replace tail.example.com with a domain you control that differs from headscale.example.com; if the two match, internal name resolution collides with the server address.
Seventh, keep metrics reachable only from the machine itself:
metrics_listen_addr: 127.0.0.1:9090
Finally, point policy at the file you will create in a later step. Mode file means policy is read from a HuJSON file on disk:
policy: mode: file path: /etc/headscale/policy.hujson
Save the file, then validate its syntax before restarting the service:
sudo headscale configtest
If it reports an error, fix the flagged line and run it again.
Step 3: Start the service and check the health endpoint
With the configuration saved and validated, restart the service:
sudo systemctl restart headscale sudo systemctl status headscale --no-pager
The expected result is active (running). If the service fails, read its log before restarting again:
sudo journalctl -u headscale -n 50 --no-pager
Next, confirm the server is reachable through its domain:
curl -s https://headscale.example.com/health
The expected result is a response showing the service is healthy. If the connection fails, check in order: DNS to the VPS IP, the firewall for TCP 443, and the service status.
Step 4: Create a user and register the first node
In Headscale, devices are called nodes, and each node belongs to one user. A user here is not a human login with a password, but a namespace grouping nodes under one owner. Management commands talk to the service through a Unix socket at /var/run/headscale/headscale.sock, accessible only to the headscale user or root by default, so the commands below use sudo.
Create a first user:
sudo headscale users create personal
Check the user list:
sudo headscale users list
The expected result lists the user you just created.
Now register the first node. The easiest automatable method is a pre-auth key, a single-use key generated on the server and pasted into the client's login command. By default, it is valid for one hour and can be used only once:
sudo headscale preauthkeys create --user personal
The command prints the key. Treat it as a credential: anyone holding it while valid can register a device into your tailnet.
Install the Tailscale client on the first device, then run the login command pointing at your own server:
sudo tailscale up --login-server https://headscale.example.com --authkey YOUR_PREAUTH_KEY
Replace YOUR_PREAUTH_KEY with the key you just generated. If it succeeds, verify from the server side:
sudo headscale nodes list
The expected result lists the first node with an address from 100.64.0.0/10, online status, and the correct user name. If the node does not appear, check whether server_url matches the login address exactly, whether the TLS certificate is valid, and whether the key has expired. A key older than an hour must be recreated.
Step 5: Register a second node and prove connectivity
One registered node proves nothing; a mesh only proves itself when two nodes reach each other. Create a fresh pre-auth key for the second node, since the previous key is already spent:
sudo headscale preauthkeys create --user personal
On the second device, run the same login command with the new key:
sudo tailscale up --login-server https://headscale.example.com --authkey YOUR_NEW_KEY
Once both nodes are registered, check status from one client:
tailscale status
Test connectivity with a ping to the other node's mesh address, for example 100.64.0.2:
ping -c 3 100.64.0.2
The expected result is replies with no packet loss. If the ping fails while both nodes show online, check the access policy in the next step, since an overly strict policy can block node-to-node traffic even when registration succeeded. Also run tailscale ping to see whether the connection is direct or relayed through DERP:
tailscale ping 100.64.0.2
A direct path means both devices punched through their NATs.
As an alternative, use web authentication for a device you hold in your hands: run tailscale up without a key, only with the server address:
sudo tailscale up --login-server https://headscale.example.com
The client prints instructions and an Auth ID. Complete registration from the server side, substituting the values shown:
sudo headscale auth register --user personal --auth-id YOUR_AUTH_ID

Step 6: Lock access down with a file-based policy
Up to this point, the tailnet runs on a permissive default policy, deliberate for testing. It should not stay once devices you do not fully control start joining. Headscale policy is written in HuJSON, a JSON variant that allows comments, following Tailscale's ACL idea: which source may reach which destination, on which port.
Create the policy file at the path set in the configuration:
sudo nano /etc/headscale/policy.hujson
A permissive starting policy, enough to guarantee nothing is blocked during testing:
{
"acls": [
{
"action": "accept",
"src": ["*"],
"dst": ["*:*"]
}
]
}
Once connectivity is proven, tighten it. The example below only allows nodes to reach each other on SSH and HTTPS; anything else is implicitly denied:
{
"acls": [
{
"action": "accept",
"src": ["*"],
"dst": ["*:22", "*:443"]
}
]
}
This is still broad on the source side, but far safer than allowing every port. For the next tightening step, replace * in the source with a specific user name, such as personal, or a tag on certain nodes, so guest devices do not get the same access as your main machines. Test ping and SSH from affected devices after every policy change, since a one-line mistake can lock you out of a server reachable only through the tailnet. Keep one public SSH path as a fallback until the new policy is proven.
Headscale ships no web dashboard for editing policy; the file on disk is the source of truth. Store the policy file in an encrypted backup.
Step 7: Add a subnet router for networks without a client
Some devices cannot run a Tailscale client at all: printers, older NAS units, or cameras on an office LAN. A subnet router solves this: one registered node announces that it will forward traffic to the network behind it.
On the future router node, enable IP forwarding in the kernel:
echo 'net.ipv4.ip_forward = 1' | sudo tee /etc/sysctl.d/99-tailscale.conf sudo sysctl -p /etc/sysctl.d/99-tailscale.conf
Then, from that router node, advertise the network you want to forward, replacing 192.168.1.0/24 with your real LAN:
sudo tailscale up --login-server https://headscale.example.com --advertise-routes=192.168.1.0/24
If the node is already registered, update its advertised routes without re-registering:
sudo tailscale set --advertise-routes=192.168.1.0/24
Announcement alone is not enough. Headscale requires explicit approval on the server before a route is used. List the announced routes:
sudo headscale nodes list-routes
The output shows node IDs, available routes, and approved routes. Approve the route you mean with the router node's ID:
sudo headscale nodes approve-routes --identifier 1 --routes 192.168.1.0/24
The expected result is a message that the node was updated. Finally, on any other node that should use the route, enable route acceptance:
sudo tailscale set --accept-routes
Test from that node with a ping to one address on the forwarded network. If it fails, check in order: IP forwarding on the router, route approval, and route acceptance on the client.
Step 8: Backups, updates, and routine monitoring
A dead control plane means new devices cannot register and policy changes do not spread, even though existing connections can survive for a while. Back up three files: the configuration, the policy, and the SQLite database:
sudo systemctl stop headscale sudo cp /var/lib/headscale/db.sqlite /root/headscale-db.sqlite.bak sudo cp /etc/headscale/config.yaml /root/headscale-config.yaml.bak sudo cp /etc/headscale/policy.hujson /root/headscale-policy.hujson.bak sudo systemctl start headscale
The service stops briefly before the database copy so the copy is consistent.
For updates, follow the rule in the project FAQ: move from one stable release to the next without skipping minor versions. If you are on 0.28.x and targeting 0.29.x, update to the latest 0.29.x first, read its release notes, and test one node registration.
Three checks catch most problems early:
sudo systemctl status headscale --no-pager sudo headscale nodes list sudo journalctl -u headscale -n 30 --no-pager
If a device that should be online shows offline, check the client side with tailscale status before touching the server configuration.
Common mistakes and how to fix them
| Symptom | Most likely cause | Fix |
|---|---|---|
| Service fails to start after a config edit | YAML syntax error or unknown key | Run headscale configtest, fix the flagged line, restart |
| Client cannot reach the server | DNS not pointing at the VPS, or TCP 443 closed | Check DNS, open TCP 443, test /health |
| TLS certificate issuance fails | tls_letsencrypt_hostname differs from the server_url domain, or another service holds port 443 | Match both domains, free port 443 |
| Node missing after login | Pre-auth key expired or already used | Create a new key, re-register |
headscale commands fail on permissions | Unix socket accessible only to headscale or root | Use sudo or add your user to the headscale group |
| Ping between online nodes fails | Access policy denies that traffic | Check policy.hujson, loosen temporarily, then tighten again |
| Subnet router forwards nothing | IP forwarding off, route unapproved, or client not accepting routes | Enable all three switches in order, retest |
| Old nodes cannot register after an update | Minor versions skipped during the update | Return to stepwise updates, read each skipped version's notes |
| Metrics exposed to the internet | metrics_listen_addr bound to a public address | Restore 127.0.0.1:9090, close port 9090 |
Architecture summary
| Component | Role | Location |
|---|---|---|
| Headscale | Control server | VPS, /etc/headscale/config.yaml |
| SQLite database | Stores users, nodes, keys | /var/lib/headscale/db.sqlite |
| HuJSON policy | Access rules | /etc/headscale/policy.hujson |
| Tailscale client | WireGuard data plane | Each node, via --login-server |
| Public DERP | Relay fallback | controlplane.tailscale.com/derpmap/default |
| MagicDNS | Internal hostnames | base_domain in the configuration |
Final checklist
- VPS runs Ubuntu 22.04 or newer, or Debian 12 or newer, domain pointing at its IP.
- Official .deb installed,
headscale versionshows the downloaded version. server_urluseshttps, same domain astls_letsencrypt_hostname.headscale configtestpasses before the service restarts.- Service
active (running),/healthreachable through the domain. - First user created, visible in
headscale users list. - Two nodes registered via pre-auth keys, able to ping each other over mesh addresses.
- Initial policy tightened from allow-all, tested from important devices.
- Subnet router, if used, passes three switches: IP forwarding, route approval, route acceptance.
- Backups of configuration, policy, and SQLite database stored off the VPS.
- Port 9090 closed to the internet, listening only on
127.0.0.1.
Which device will you connect first to your own tailnet, and which access rule is hardest to phrase for it? Share it in the comments.
Read also: How to Install Dozzle with Docker: Watch Container Logs from Your Browser as the paired article in the same batch, and an older relevant article: Tailscale on a VPS and Homelab: A Private Mesh VPN Without Opening Ports.
Diskusi
Ada pertanyaan atau pengalaman yang ingin dibagikan?
Komentar ditinjau sebelum ditampilkan. Mari berdiskusi dengan sopan dan sesuai topik.
Tulis komentar