# Tailscale / tailnet debugging from Termux (non-root) Use when the user can't reach a tailnet service (browser, curl, ssh) from the phone and tailscaled runs as a Termux app rather than the official Android app. ## 0. Establish how tailscaled actually runs (before any fix) ```bash ps -ef | grep tailscaled cat /proc//cmdline | tr '\0' ' ' ``` - `--tun=userspace-networking` means the daemon can only offer a local SOCKS5/HTTP proxy (address in `--socks5-server=…`); there is NO device-wide VPN and NO system-DNS interception. Expect stock App-level tailnet access to fail in this mode — the fix is a real VPN path (official Tailscale app) or a TUN-capable proxy client, not curl flags. - `--socket=` in the cmdline is the source of truth for where the daemon listens; it is often NOT the path the CLI dials by default. ## 1. Wire the CLI to the running daemon (socket-mismatch trap) CLI keeps erroring `dial unix $PREFIX/tmp/tailscaled.sock: no such file or directory` even though tailscaled is running → it is dialing its default path, not the daemon's socket. Some Termux CLI builds ignore `TS_SOCKET`/`TAILSCALE_SOCKET` and keep using the default; stop chasing env vars and use the symlink, which verified works: ```bash ln -sF /data/data/com.termux/files/usr/tmp/tailscaled.sock tailscale status # must now list peers ``` ## 2. Verify the NAME before blaming the tunnel ```bash tailscale status # peer hostnames + 100.64/10 IPs + live state tailscale status --json | python3 -c 'import sys,json; d=json.load(sys.stdin); print(d["Self"]["DNSName"]; [ (k,v["Hostname"]) for k,v in d["Peers"].items() ]') ``` - MagicDNS peer name form is `.ts.` — `Self.DNSName` shows the exact form, don't guess it. - If the user's typed name isn't a peer (e.g. missing the `.ts.` part), it is very likely a PUBLIC DNS name that just shares the domain. Cross-check with the system resolver (`getent hosts X`, plain `ping X`): if it lands on a non-100.x IP, the traffic was never tailnet traffic — diagnose it as an ordinary web service (redirects, TLS, auth) instead of tunneling. ## 3. Probe reachability through the daemon (works even in userspace mode, no TUN needed) ```bash # remote-DNS variant (socks5h) makes tailscaled resolve AND route the name; # -sv to capture the discriminating line curl --socks5-hostname 127.0.0.1: -sv -o /dev/null --max-time 6 \ http://:/ 2>&1 | grep -iE 'trying|opened|socks|refused|timed|connect' ``` Isolation ladder, cheapest first: 1. **Baseline control**: any public host/IP (e.g. `socks5h://1.1.1.1:443`). FAILs → the proxy itself is down (check the socks port from cmdline is listening) — stop, this is not a peer problem. 2. **Peer by name**: `cannot complete SOCKS5 connection … (1)` while control passed → name or peer path. 3. **Peer by raw 100.x IP** at the same port AND at ports that are usually open (22): - still failing → the peer/tunnel path itself is broken (wireguard or user-space forwarding), not DNS and not port choice. Do NOT keep guessing ports. Check the peer's live state in `tailscale status` (active vs idle, tx/rx), re-`up`/re-auth, or fall back to the official app for app-level access. - passing, name failing → DNS record/naming problem, or the service genuinely isn't listening on the guessed port. 4. **Refused vs timeout**: `connection refused` = peer reachable, no listener on that port (harmless — try another port). Timeout or SOCKS-level failure = no route. ## 4. Browser access (stock Chrome on Android) - Stock Chrome on Android cannot be pointed at a local SOCKS5/HTTP proxy. In userspace-daemon mode, "open in Chrome" fails by design — say so directly instead of re-probing. - Clean fix: install the official Tailscale app (Play Store / F-Droid), log into the same tailnet → device-wide VPN + DNS. Then the correct `.ts.:` opens in Chrome with no extra config. - Proxy-only fallback: a SOCKS-capable browser (e.g. Kiwi) or a TUN-mode proxy client (NekoBox/KitsuneBI) importing `socks5 127.0.0.1:`. ## Anti-patterns - Don't conclude "Tailscale is broken" from a single failed name: verify name validity (§2) and baseline control (§3.1) first — the name may simply not be tailnet traffic. - Don't blame DNS when the raw-100.x-IP probe also fails — that's a routing/peer problem. - Don't present a proxy-only (userspace) setup as an app-level workaround: it cannot intercept stock browser traffic, ever.