brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: tailscale wait blocks a script until Tailscale is ready

Network and access
~/tips/tip-tailscale-wait-for-interface

tailscale wait && /path/to/service

Pauses a script or service start until the Tailscale interface and its addresses are available.

Services that bind to a Tailscale address sometimes start before Tailscale itself is up after a boot. The result is an error about an address that does not exist yet.

tailscale wait && /path/to/service
tailscale wait --timeout=30

According to the Tailscale CLI reference, tailscale wait waits for Tailscale resources to become available for binding, within a timeout or indefinitely. It exits with 0 on success and with a non-zero code on a failure or timeout, so && only starts the service when the wait worked.

The one flag is --timeout, in seconds. A value of 0 means wait forever. Without it, the command waits until Tailscale is ready.

The docs also show a way to wait for an address:

tailscale wait && tailscale ip --assert=100.x.y.z

Replace the placeholder with the address of your own machine. On Linux with systemd, the docs say you can order a unit after tailscale-online.target, which runs this command for you.

The caveat is the version and what it waits for. The reference says that as of Tailscale 1.96 the only resource available to wait for is the Tailscale interface and its IPs. It says nothing about other devices being reachable. In userspace networking mode there is no real interface, so the command only waits for tailscaled and the Running state. Check tailscale version first, because older clients do not have the command.

Further reading: Tailscale docs: CLI reference (wait)

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link