# Reliability, zero-downtime updates, and BGP failover

Source: https://prontaro.com/docs/outbound/failover/

Your dedicated static IPv4 and tunnels run on Prontaro's own AS403244 network independently of the dashboard and API, with routine updates draining active traffic cleanly.

During a rare hardware outage or server reboot, your address moves automatically to a standby server in the same location — same IP, no allowlist, DNS, or firewall changes.

| Event | Active connections | New requests & connections | Action needed |
| --- | --- | --- | --- |
| **Dashboard or API maintenance** | Keep running uninterrupted | Served from each server’s local snapshot | None — only config edits wait |
| **Routine Prontaro server update** | Drain cleanly on the old process (up to 30 min) | Served immediately by the new version on the same server | None |
| **`prontaro CLI` update (Linux)** | Active tunnel sessions finish on the old process | New visitors route to the new binary without pause | Run `prontaro update` and `systemctl reload` |
| **Rare server outage or reboot** | Open TCP sockets close | Routed to the standby server on the same `/32` IP | `prontaro CLI` reconnects automatically; HTTP clients retry |

## If the dashboard or API is down

- Active dedicated IPs, HTTP/SOCKS5 proxies, Relay URLs, and running HTTPS/TCP tunnels keep serving traffic without interruption.
- `prontaro CLI` caches the last working entry address locally and can reconnect to the Prontaro server even while the API is unreachable.
- Only configuration changes (creating or deleting credentials, adding Relays, editing firewall or access rules) wait until the API is back.

## Zero-downtime updates

### Server hot upgrades

Prontaro updates servers in place on the same machine: open connections finish in the previous process, while new ones go straight to the updated version. BGP routes and IP bindings stay as they are.

Connections still open after 30 minutes close when the previous process exits; an idle SOCKS5 stream may close earlier.

### Zero-downtime `prontaro CLI` updates

On Linux, `prontaro CLI` supports live process handoff for running HTTPS and TCP tunnels (`prontaro http`, `prontaro tcp`, `prontaro run`) without dropping active connections:

1. Update the binary:

```bash
prontaro update
```

1. Reload the `systemd` service or send `SIGUSR2` to a foreground process:

```bash
# If running as a systemd user service:
systemctl --user reload prontaro-<name>

# For a system service (--system):
sudo systemctl reload prontaro-<name>

# If prontaro is running in a terminal:
kill -USR2 <PID>
```

Open connections stay up. If the new version fails to start, the previous one keeps serving your tunnels.

> **OS support and scope for CLI hot handoff**
>
> - **Linux only.** On Windows and macOS, the new version takes over after you restart the tunnel ([Background services](https://prontaro.com/docs/cli/service.md)).
> - **Full restarts** (`systemctl restart`, a reboot, or device sleep) close open connections.
> - **`prontaro forward`:** the local port briefly re-binds — a new local connection in that moment may be refused.

## Automatic BGP failover

- **Automatic BGP shift.** If the primary server fails or stops announcing the route, your `/32` moves to the standby automatically.
- **No IP leaks.** Each outbound socket binds strictly to your `/32`. If `/32` is momentarily absent during transition, the server returns HTTP `503` instead of falling back to a host IP.

### Connection behavior during a full-server failover

When a server fails or reboots, open TCP sessions close and new connections go straight through the standby server:

| Connection type | During switch to standby | Recovery |
| --- | --- | --- |
| **HTTP / SOCKS5h proxy** | Active requests disconnect or return `503` | Retry the request using the same URL and credentials |
| **Relay URLs** | Active HTTP requests fail with a network error or `502`/`503` | Retry the same Relay URL |
| **`prontaro forward`** | Open TCP streams disconnect; `127.0.0.1:<port>` stays open | New local connections wait and connect once the server responds |
| **Inbound tunnels (`http`/`tcp`)** | Active visitor sessions disconnect | `prontaro CLI` reconnects automatically to the standby server (short backoff, 0 to ~4.8 s) |

## Production best practices

Standard client-side resilience absorbs network glitches, partner API restarts, and rare BGP failovers alike:

1. **Bounded retries with backoff and jitter.** Retry transient network errors and `502`/`503`. A 12–15 second window (`1s → 3s → 8s` + jitter) covers a typical BGP switch, though the exact switchover time is not guaranteed.
2. **`Idempotency-Key` on writes.** Retry idempotent methods (`GET`, `HEAD`, `PUT`, `DELETE`) freely; retry `POST` calls (charges, order creation) only when protected by an `Idempotency-Key`.
3. **Database pool socket validation for `prontaro forward`.** Configure your database driver (`pg`, `SQLAlchemy`, `Prisma`, `mongodb`) to validate and automatically replace dropped connections.

Example Node.js (`undici`) wrapper:

```js
import { fetch, ProxyAgent } from "undici";

const dispatcher = new ProxyAgent(process.env.PRONTARO_PROXY_URL);
const RETRY_DELAYS_MS = [1_000, 3_000, 8_000]; // >12s total to cover route convergence
const IDEMPOTENT_METHODS = new Set(["GET", "HEAD", "PUT", "DELETE"]);

export async function callPartner(path, { method = "GET", body, idempotencyKey } = {}) {
  const canRetry = IDEMPOTENT_METHODS.has(method.toUpperCase()) || Boolean(idempotencyKey);
  const maxAttempts = canRetry ? RETRY_DELAYS_MS.length + 1 : 1;

  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
    try {
      const res = await fetch(`https://api.example.com${path}`, {
        method,
        dispatcher,
        headers: {
          "content-type": "application/json",
          ...(idempotencyKey ? { "idempotency-key": idempotencyKey } : {}),
        },
        body: body ? JSON.stringify(body) : undefined,
        signal: AbortSignal.timeout(10_000),
      });
      if ((res.status !== 502 && res.status !== 503) || attempt === maxAttempts) {
        return res;
      }
    } catch (err) {
      if (attempt === maxAttempts) throw err;
    }

    const base = RETRY_DELAYS_MS[attempt - 1];
    const jitter = Math.floor(Math.random() * 500);
    await new Promise((r) => setTimeout(r, base + jitter));
  }
}

// Safe GET — automatically retried across transient network errors or a server switch:
const statusRes = await callPartner("/v1/status");
```

## Scope and multi-region redundancy

- **BGP failover stays within one location.** Your `/32` IPv4 moves between primary and standby servers in your chosen location, not across continents.
- **Multi-region active-active.** Use Pro (2 IPs included, up to 5 total) to provision IPs in two locations and fail over in application code.
- **Quotas apply across both servers.** Failover does not bypass billing limits: at 100% monthly traffic usage, both servers stop forwarding new requests until you buy an extra traffic pack or the next billing period begins.

## FAQ

### How can I distinguish a failover from an access or limit refusal?

Access and limit errors (not transient outages) return explicit HTTP status codes — such as invalid credentials (`407 access_denied`), From/To rule blocks (`403 source_denied`, `403 target_denied`), built-in destination blocks (`403 destination_denied`), or exhausted traffic (`403 volume_exhausted`) — and appear immediately in [Logs](https://my.prontaro.com/journal) in the dashboard.

A server switch causes a TCP disconnect, timeout, or `503 proxy_unavailable`. On machines with the CLI, you can also run `prontaro doctor`.

## Next steps

- [Dedicated static IPv4](https://prontaro.com/docs/outbound/static-ip.md) — how your dedicated IP works, locations, and reverse DNS (PTR).
- [Background services (Linux & macOS)](https://prontaro.com/docs/cli/service.md) — run persistent tunnels and `prontaro forward` under systemd or launchd.
- [Connection logs](https://prontaro.com/docs/billing/logs.md) — inspect access and quota refusals in the dashboard.
- [Diagnostics and error codes](https://prontaro.com/docs/cli/errors.md) — reference for CLI error codes and proxy status reasons.
- [Usage, limits & quotas](https://prontaro.com/docs/billing/limits.md) — traffic allowances, connection limits, and add-on packs.
