Reconnect Cloudflare WARP automatically on Mac
A DockRun workflow that watches Cloudflare WARP and brings it back when it drops: reconnect over HTTPS, rotate the keys, then return to UDP.
The button needs DockRun 0.1.19 or later. On an older version, download the file, then use Settings > Restore or Import… in DockRun.
Runs in DockRun Free, which holds 2 workflows.
What it does
- Checks WARP every 10 seconds in the background.
- When WARP drops, it reconnects over HTTPS (MASQUE over HTTP/2), runs warp-cli tunnel rotate-keys, then switches back to UDP (HTTP/3).
- If UDP is blocked on the network, it goes back to WARP's default so you are not left offline.
- Leaves WARP alone when you turned it off yourself.
You need
Cloudflare WARP with warp-cli installed at /usr/local/bin/warp-cli (the consumer WARP app installs it).
The steps
Read the script below before you add it. It is everything this workflow runs.
- 1. Start the WARP watcherRuns this zsh script · Time limit: 60 seconds
# Watches Cloudflare WARP. When it drops (not when you turn it off yourself), reconnects over # HTTPS/TCP (MASQUE h2-only), rotates the tunnel keys, then goes back to UDP (MASQUE h3-only). WARP=/usr/local/bin/warp-cli LOG="$HOME/Library/Logs/DockRun-warp-reconnect.log" PIDFILE="${TMPDIR:-/tmp}/dockrun-warp-watch.pid" [ -x "$WARP" ] || { echo "warp-cli not found at $WARP"; exit 1; } log() { echo "$(date '+%F %T') $*" >> "$LOG"; } state() { "$WARP" status 2>&1 | head -1; } wait_connected() { # $1 = seconds to wait local i; for i in $(seq "$1"); do case "$(state)" in *Connected*) return 0;; esac; sleep 1; done; return 1 } repair() { log "WARP dropped: $(state). Reconnecting over HTTPS (h2-only)." "$WARP" tunnel masque-options set h2-only >> "$LOG" 2>&1 "$WARP" connect >> "$LOG" 2>&1 wait_connected 30 || log "HTTPS did not connect within 30s; rotating keys anyway." "$WARP" tunnel rotate-keys >> "$LOG" 2>&1 "$WARP" tunnel masque-options set h3-only >> "$LOG" 2>&1 "$WARP" connect >> "$LOG" 2>&1 if wait_connected 30; then log "Back on UDP (h3-only)."; return 0; fi # UDP is blocked on this network: allow the HTTPS fallback again rather than staying offline. log "UDP did not connect within 30s; back to the default (UDP with HTTPS fallback)." "$WARP" tunnel masque-options reset >> "$LOG" 2>&1 "$WARP" connect >> "$LOG" 2>&1 } if [ "$1" = "repair-now" ]; then repair; state; exit 0; fi if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then echo "Already watching WARP (pid $(cat "$PIDFILE")). Now: $(state)"; exit 0 fi ( drops=0 while true; do s="$(state)" case "$s" in *Disconnected*Manual*) drops=0 ;; # you turned it off: leave it alone *Disconnected*) drops=$((drops + 1)); [ "$drops" -ge 2 ] && { repair; drops=0; } ;; *) drops=0 ;; esac sleep 10 done ) > /dev/null 2>&1 & echo $! > "$PIDFILE" disown log "Watcher started (pid $(cat "$PIDFILE"))." echo "Watching WARP every 10s (pid $(cat "$PIDFILE")). Now: $(state). Log: $LOG"
After you add it
- DockRun shows what is in the file and asks before adding it. The workflow arrives turned off.
- Open it, read the steps, then turn on the On switch.
- Press Run. DockRun asks before a script runs; tick "Don't ask again for this exact step" once you trust it.
- To have it start by itself, turn on Run on an event and choose "DockRun starts up" (Pro).
Good to know
Each repair is written to ~/Library/Logs/DockRun-warp-reconnect.log. The watcher stops when you restart the Mac.
Last tested: 2026-11-12 · All workflows →