Copy .env.example to .env and set the two required variables:
Terminal window
cp.env.example.env
Terminal window
copy .env.example .env
Edit the .env file with your auth key and target:
.env
TS_AUTHKEY=tskey-auth-KEYID-SECRET# From Tailscale admin console
TS_TARGET=100.82.151.104:3389# Host Tailscale IP + port
Then restrict it, because an auth key is a credential and .env is world-readable by default:
Terminal window
chmod600.env
Security note: A key in .env or in the environment is readable by any child process, and
--auth-key on the command line is visible in the process list to every user on the machine. For
a shared or hardened host, keep the key in its own file and pass --auth-key-file instead — the
binary never sees the value in the argument vector:
Auth key. Tailscale: generate here. Headscale: headscale preauthkeys create. Format: tskey-auth-<id>-<secret> or hskey-*. Plaintext in the environment. On a shared or hardened host, connect --auth-key-file can leave it unset; init --auth-key-file avoids command-line exposure but writes TS_AUTHKEY to the generated .env (or the sibling .env in YAML mode).
tskey-auth-KEYID-SECRET
TS_TARGET
Host address on the mesh network. Supports IP or MagicDNS hostname.
Local bind address. Auto-derived in auto mode when unset.
TS_CONTROL_URL
(Tailscale default)
Custom control plane URL for self-hosted Headscale. Required for hskey- keys — they are rejected without it (a tskey- key routes to Tailscale SaaS by default). Must be an http(s):// URL.
TS_HOSTNAME
ts-bridge
Node name in the admin console. Auto-generated per run in auto mode.
TS_STATE_DIR
(per-user)
Directory for node state (holds the private node identity). Default is a fixed per-user dir (e.g. ~/.local/state/ts-bridge/state on Linux, %LOCALAPPDATA%\ts-bridge\state on Windows). Created with 0700 permissions. Ephemeral temp dir in auto mode with an instance. A relative override is warned about.
TS_AUTO_INSTANCE
true
Auto mode toggle. Set false to disable auto behavior.
TS_MANUAL_MODE
false
Force legacy persistent mode. Takes precedence over TS_AUTO_INSTANCE.
TS_INSTANCE_NAME
(empty)
Stable instance alias for deterministic local port selection.
TS_PORT_RANGE
33389-34388
Port range for auto mode (START-END).
TS_TIMEOUT
30s
Timeout for tsnet initialization (control-plane handshake). Go duration format.
TS_DIAL_TIMEOUT
5s
Per-connection target dial timeout, distinct from TS_TIMEOUT. Keeps stuck dials from holding a slot across retries. Go duration format. (v1.8.0+)
TS_DRAIN_TIMEOUT
15s
Timeout for graceful drain of active connections on shutdown. Go duration format.
TS_MAX_CONNECTIONS
1000
Maximum concurrent connections before rejecting new ones.
TS_IDLE_TIMEOUT
(disabled)
Close connections after this period of no traffic in either direction. Go duration format (e.g. 30m). Default 0 disables. Useful for reclaiming slots from abandoned RDP sessions. (v1.6.0+)
TS_DIAL_RETRIES
3
Maximum retries for transient target dial failures. 0 disables retry. (v1.7.0+)
TS_DIAL_BACKOFF_BASE
1s
Base backoff for dial retries (multiplied by 2^attempt, plus jitter). Go duration format. (v1.7.0+)
TS_DIAL_BACKOFF_MAX
30s
Cap on backoff per retry attempt. Must be ≥ TS_DIAL_BACKOFF_BASE. (v1.7.0+)
host check exits 0 when every step is ok, 2 when any step is not (it would change, failed, needs a manual action or could not be read), and 1 on error.
host check exits 0 when every step is ok, 2 when any step is not (it would change, failed, needs a manual action or could not be read), and 1 on error.
Host setup is not applicable on macOS. macOS machines act as clients only — use ts-bridge connect to connect to a remote Windows or Linux host.