Headscale¶
Prefer one command? Try the Headscale Playbook
Headscale is a self-hosted control server for Tailscale clients. It coordinates your devices; their encrypted traffic travels directly between peers or through external DERP relays. This guide installs the latest stable release with SQLite. The Headscale Playbook automates these steps.
Note
You should be familiar with systemd services, domains, and web backends. Use a fresh Asteroid with port 8080 available. Example output below is abbreviated.
Installation¶
Resolve the latest release and download its Linux AMD64 binary and checksums into a private directory:
[isabell@moondust ~]$ latest=$(curl -fsS --retry 3 https://api.github.com/repos/juanfont/headscale/releases/latest | jq -er '.tag_name')
[isabell@moondust ~]$ echo "$latest"
v0.29.8
[isabell@moondust ~]$ mkdir -m 700 ~/.headscale
[isabell@moondust ~]$ cd ~/.headscale
[isabell@moondust .headscale]$ binary="headscale_${latest#v}_linux_amd64"
[isabell@moondust .headscale]$ curl -fL --retry 3 -O "https://github.com/juanfont/headscale/releases/download/$latest/$binary"
[...]
[isabell@moondust .headscale]$ curl -fL --retry 3 -O "https://github.com/juanfont/headscale/releases/download/$latest/checksums.txt"
[...]
[isabell@moondust .headscale]$ sha256sum --check --ignore-missing checksums.txt
headscale_0.29.8_linux_amd64: OK
[isabell@moondust .headscale]$ chmod 700 "$binary"
[isabell@moondust .headscale]$ ln -s "$binary" headscale
curl -f fails on HTTP errors and --retry 3 retries temporary failures. jq -er extracts the tag as text and fails if it is absent. ${latest#v} removes the leading v for the binary filename. Stop on any error or checksum mismatch; do not execute an unverified download.
Configuration¶
Download the example configuration from the same release:
[isabell@moondust .headscale]$ curl -fL --retry 3 -o config.yaml "https://raw.githubusercontent.com/juanfont/headscale/$latest/config-example.yaml"
[...]
[isabell@moondust .headscale]$ chmod 600 config.yaml
Edit ~/.headscale/config.yaml. Change the following fields within the existing sections; do not append duplicate keys. Replace isabell in the paths and domain:
server_url: https://isabell.uber.space
listen_addr: 0.0.0.0:8080
metrics_listen_addr: ""
grpc_listen_addr: 127.0.0.1:0
tls_cert_path: ""
tls_key_path: ""
unix_socket: /home/isabell/.headscale/headscale.sock
unix_socket_permission: "0600"
disable_check_updates: true
noise:
private_key_path: /home/isabell/.headscale/noise_private.key
database:
type: sqlite
sqlite:
path: /home/isabell/.headscale/db.sqlite
dns:
base_domain: tailnet.isabell.uber.space
override_local_dns: false
Keep the rest of the release configuration, including its address prefixes and external DERP map. Leave derp.server.enabled set to false: this guide does not expose a UDP STUN server. Uberspace terminates HTTPS; Headscale listens on 0.0.0.0 so the web proxy can reach it. Its admin Unix socket stays private, remote gRPC is bound to an ephemeral loopback port, and metrics are disabled.
base_domain is the suffix used for MagicDNS names inside your tailnet, not your public server address. The configuration preserves your devices' existing DNS resolvers. Review Headscale's access policy documentation before adding other users: the default policy permits communication between peers.
Validate the configuration; Headscale generates the missing Noise key when needed:
[isabell@moondust ~]$ ~/.headscale/headscale --config ~/.headscale/config.yaml configtest && echo 'Configuration is valid'
[...]
Configuration is valid
Service and backend¶
Create a systemd service:
[isabell@moondust ~]$ uberspace service add headscale "$HOME/.headscale/headscale --config $HOME/.headscale/config.yaml serve" --workdir "$HOME/.headscale" --directive Restart=on-failure --directive RestartSec=5 --directive UMask=0077
OK: Created service file: /home/isabell/.config/systemd/user/headscale.service
[...]
[isabell@moondust ~]$ uberspace web backend add "${USER}.uber.space/" port 8080 --force --wait
[...]
OK: Your webserver configuration has been adapted
[isabell@moondust ~]$ curl -fsS "https://${USER}.uber.space/health"
{"status":"pass"}
Register devices¶
Manage Headscale over SSH. Create a user and list its numeric ID:
[isabell@moondust ~]$ ~/.headscale/headscale users create alice
[...]
[isabell@moondust ~]$ ~/.headscale/headscale users list
ID | Name | Username | Email | Created
[...]
Install a Tailscale client on your own computer or phone. Follow the Headscale client instructions for that operating system and set the login server to https://isabell.uber.space.
The client will show a registration link. Open it and run the displayed approval command over SSH on your Asteroid for your Headscale user. All commands on the Asteroid run as your regular user, without sudo. The Asteroid runs the Headscale server; install the Tailscale client on the devices you want to connect.
Confirm enrollment:
[isabell@moondust ~]$ ~/.headscale/headscale nodes list
ID | Hostname | Name | MachineKey | NodeKey | User | IP addresses | Ephemeral | Last seen | Expiration | Connected | Expired
[...]
Alternatively, generate a short-lived, single-use preauthentication key with headscale preauthkeys create --user ID and use it on your client. Treat it as a password; avoid sharing it or placing it in scripts committed to Git.
Debugging¶
A plain browser visit to the server root is not a management interface. Use /health to check availability and the CLI over SSH to manage devices.
[isabell@moondust ~]$ systemctl --user is-active headscale
active
[isabell@moondust ~]$ journalctl --user -u headscale -n 50
[...]
... listening and serving HTTP on: 0.0.0.0:8080
For startup errors, rerun configtest and check paths and permissions. If health works but enrollment fails, check that server_url exactly matches the public HTTPS address and that the client meets the release's minimum version. Inspect the service journal during enrollment.
Updates¶
Note
Read the release notes and upgrade guide. Do not skip minor versions; major configuration or database changes can require intermediate upgrades.
Stop Headscale and back up the complete directory, including its configuration, keys, and SQLite journal files:
[isabell@moondust ~]$ umask 077
[isabell@moondust ~]$ systemctl --user stop headscale
[isabell@moondust ~]$ tar -czf "$HOME/headscale-backup-$(date +%Y%m%d-%H%M%S).tar.gz" -C "$HOME" .headscale
[isabell@moondust ~]$ ls "$HOME"/headscale-backup-*.tar.gz
/home/isabell/headscale-backup-[...].tar.gz
Keep a private copy outside the Asteroid. Download the next supported release and its checksums using the Installation commands, without recreating the directory. Set latest to the required intermediate tag when necessary. Verify the checksum, make the binary executable, then replace the symlink with ln -sfn "$binary" headscale from ~/.headscale.
Compare the new release's example configuration with your existing configuration; preserve your paths, keys, database, domain, and policy. Validate it before restarting:
[isabell@moondust ~]$ ~/.headscale/headscale configtest && systemctl --user start headscale
[isabell@moondust ~]$ curl -fsS "https://${USER}.uber.space/health"
{"status":"pass"}
Verify that existing devices reconnect. A rollback must restore the matching binary, configuration, and database from the backup while the service is stopped; switching the binary alone cannot undo a database migration.