Auto-Reconnect
Automatic recovery when your tunnel connection drops
Overview
zgrok automatically reconnects when the tunnel connection drops. The CLI retries with exponential backoff, and asks for the same address when it comes back.
How it works
When the connection to the relay server is lost:
- zgrok detects the disconnection
- Waits with exponential backoff: 1s → 2s → 4s → 8s → 16s → 30s (max)
- Attempts to reconnect and re-authenticate
- Shows progress in the terminal:
✗ The relay is restarting. Reconnecting↻ Reconnecting in 1s... (attempt 1/10)↻ Reconnecting to relay.zgrok.io:4433...→ Authenticating...Tunnel Status: onlineProject: acme-shop (switch: zgrok project)Forwarding: https://a7f9x2--acme-shop.zgrok.io → http://localhost:3000
The first line names the reason. A relay restart reads as above; a network drop reads Connection lost, followed by what the connection reported.
A dropped network is not noticed at once. When the relay simply stops answering, the CLI waits up to 5 minutes before it gives the connection up, and only then does the countdown start. If you can see the tunnel is dead, Ctrl+C and a new zgrok http is faster, but on Free it also gives you a new address.
What happens to your address
- The address normally comes back. The CLI remembers the name it was given and asks for it again, on every plan. If you deleted the tunnel in the dashboard meanwhile, it gets a new name and says so.
- On Free, an assigned address lasts at most 24 hours. At that point the relay ends the session, the CLI says
This address reached its 24-hour limit. Reconnecting with a new one, and the tunnel continues under a new name. - Requests that were in flight are lost. So is anything sent while the tunnel is down: visitors get an error page until it is back, and zgrok does not queue or resend.
Limits
- Maximum attempts: 10 in a row (then exits with an error). A connection that stayed up for a minute starts the count again
- Maximum delay: 30 seconds between attempts
- Auth errors do NOT reconnect: if your API key is invalid, zgrok exits immediately. The exception is a fault on our side, which is retried like a dropped connection
Cancel reconnect
Press Ctrl+C during the reconnect wait to cancel and exit:
↻ Reconnecting in 8s... (attempt 4/10)^C→ Cancelled
Disable auto-reconnect
In your config file (~/.zgrok/config.yaml):
auto_reconnect: falseWith auto-reconnect disabled, zgrok exits immediately when the connection drops.
See also
- Configuration: all config options
- Troubleshooting: connection issues