# Connect and pair

> Pair browsers and phones with the Gateway and reach the Control UI over Tailscale

- 网址：https://funcoding.ai/agents/openclaw/web/control-ui/connect-and-pair/
- 来源：OpenClaw 官方文档原文（英文），MIT 许可，同步于 2026-11-30
- 官方原文：https://docs.openclaw.ai/zh-CN/web/control-ui/connect-and-pair

---
Reach the Control UI from a new browser, phone, or network, and fix the connection when it fails.

If the page says **No access to this Gateway**, automatic retries stop. Sign in as
a different user or ask a Gateway administrator to grant your account operator
access, then choose **Connect**. Returning to the tab or restoring your network
does not retry an access denial. Temporary connection failures still reconnect
with capped exponential backoff and jitter.

## Device pairing (first connection)

After gateway auth succeeds, connecting from a new browser or device usually requires a **one-time pairing approval**, shown as `disconnected (1008): pairing required`. On the Gateway host, `openclaw dashboard` is the preferred owner path: it opens a short-lived, single-use pairing link and leaves that exact signed browser with a durable administrator credential. Opening a fresh link in the same browser also repairs a previously limited credential; another browser profile cannot inherit or replay the grant.

**List pending requests**

```bash
openclaw devices list
```

**Approve by request ID**

```bash
openclaw devices approve <requestId>
```

If the Gateway runs under a named CLI profile, use that profile on the host. For example, for a Gateway started with `--profile work`, run `openclaw --profile work devices approve <requestId>` to approve the browser or `openclaw --profile work gateway auth-token --show` to retrieve its token. Without `--profile`, a fresh shell targets the default profile.

Keep the page open while approval is pending. It waits for the decision and connects on its own once the request is approved; **Check now** lets you retry immediately.

If the operator rejects this browser's request from the CLI or **Devices**, the
waiting page shows **Access request declined** and stops automatic retries.
Choose **Request again** to file another request. An unanswered request shows
**Access request expired**, not declined. These outcomes belong to the live
connection, not stored denial history: reloading the page may request approval
again. Rejecting one browser does not affect another browser's pending request.

If the login screen says **Pairing link is no longer valid**, the one-time dashboard
link may have expired or already been used. Run `openclaw dashboard` on the Gateway
host and open the fresh link it opens or copies. Without browser or clipboard access
on that host, run `openclaw dashboard --json` and open its `browserUrl` within ten
minutes. This error does not mean the shared Gateway token or password needs changing.

If the browser retries pairing with changed auth details (role/scopes/public key), the previous pending request is superseded and a new `requestId` is created; re-run `openclaw devices list` before approving.

Switching an already-paired browser from read access to write/admin access normally requires an approval upgrade: OpenClaw keeps the old approval active, blocks the broader reconnect, and asks you to approve the new scope set explicitly. Eligible local connections can auto-approve scope upgrades under the conditions below. A fresh owner handoff issued on the Gateway host by `openclaw dashboard` or graphical onboarding can also upgrade only the same signed browser that redeems that one-time handoff.

If this browser needs administrator access, open **Settings > Profile > Your access** and click **Request admin**. The browser files the pending device scope-upgrade request over its existing connection; run the displayed `openclaw devices approve <requestId>` command on the Gateway host or approve from **Devices** in another admin-capable browser that also has `operator.pairing`. Keep the requesting tab connected while approval completes so it can receive and store the freshly rotated device token before reconnecting. **Retry** reattaches to the pending request. **Cancel** stops the local wait but does not reject the device request; if you cancel or disconnect before approval, use the normal pairing repair path on the next connection.

Limited access is not an Inbox notification. If your assigned role cannot grant administrator access, this section explains the limit without offering **Request admin**. Ask a Gateway administrator to change the role, then reconnect. Once the role permits administrator access, **Request admin** becomes available for this browser; separate device approval is still required. Requesting access does not grant it automatically.

If the device was previously approved for admin access but its token was later narrowed, approving the request preserves that token limit. The UI explains that pairing was approved without restoring the requested access, rather than reporting rejection or offering a retry that cannot lift the limit. Run `openclaw dashboard --json` on the Gateway host and open its fresh one-time `browserUrl` in the same browser to restore administrator access through the owner handoff.

For a LAN or remote browser, keep the same Control UI origin and Gateway URL so the handoff repairs the existing browser identity. If `browserUrl` uses loopback, replace its base address with the current Control UI address and its `gatewayUrl` fragment parameter with the current Gateway WebSocket URL. Preserve the remaining one-time pairing fragment values, and open the link within ten minutes. Only use addresses for the same Gateway; do not send the pairing link to another host.

Once approved, the device is remembered and won't require re-approval unless you revoke it with `openclaw devices revoke --device <id> --role <role>`. See [Devices CLI](https://funcoding.ai/agents/openclaw/cli/devices/) for token rotation, revocation, and the Paperclip / `openclaw_gateway` first-run approval flow.

If the Gateway denies the upgrade because it exceeds your assigned operator role, the access details show the administrator-change guidance without **Retry**. An administrator must change the role before the request can succeed; device approval cannot override that ceiling. **Retry** remains available for pending, rejected, or expired approval requests and retryable failures. **Cancel** clears the local request state so you can make a new request after the underlying problem is resolved.

<div class="callout callout-note">

- Direct local Control UI connections from a loopback TCP peer (`127.0.0.1` or `::1`, typically reached as `localhost`) with no forwarded/proxy headers can auto-approve device pairing only after gateway auth succeeds and the browser presents device identity. In token/password mode, the first connection still needs the configured shared secret; this auto-approval is not a token bypass.
- A Control UI browser in WebChat mode also qualifies as local when the TCP peer is private or loopback (including CGNAT), both `Host` and `Origin` name loopback hosts, no forwarded/proxy headers are present, and shared token/password authentication succeeds. This supports Docker-published ports opened through `localhost`, where the Gateway may see a private container-network peer instead of `127.0.0.1`. The browser must still present its signed device identity; a private peer address alone is insufficient.
- Local scope upgrades additionally require the connection itself to authenticate with local-grade credentials (`none`, the shared token, or the shared password). A stored device token does not satisfy that requirement. Set `gateway.nodes.pairing.autoApproveLocal: false` to require explicit approval for local pairing and access upgrades.
- Direct loopback needs no shared secret only when `gateway.auth.mode: "none"` is explicitly configured. That disables gateway auth and is not the recommended Control UI setup. Tailscale Serve and trusted-proxy modes can avoid a pasted shared secret only when their respective identity checks succeed.
- Tailscale Serve can skip the pairing round trip for Control UI operator sessions when `gateway.auth.allowTailscale: true`, Tailscale identity verifies, and the browser presents its device identity. Device-less browsers and node-role connections still follow the normal device checks.
- Direct Tailnet binds and LAN browser connects still require explicit approval. Browser profiles without device identity cannot use loopback auto-approval.
- Each browser profile generates a unique device ID, so switching browsers or clearing browser data requires re-pairing. On HTTPS and loopback origins, simultaneous first visits in the same profile share that identity. On non-loopback plain HTTP, connect one tab before opening others; cross-tab identity coordination requires the browser's secure-context Web Locks API.
- Private windows and browser profiles that discard site data on exit, including Firefox Never remember history, also discard the stored device identity and per-device token. They will appear as a new browser after each restart; use a persistent browser profile to stay paired, and remove stale entries with `openclaw devices remove <deviceId>` when the paired-device list grows.

</div>

## Pair a browser with a code

Use this when your own browser has no Gateway token and you can run a command on the Gateway host, including over SSH. You do not need a browser on the host, and nothing has to be pasted into the page. Approval grants administrator access; this is not a guest invitation.

Code pairing is for a direct connection to the Gateway serving the page, not an OpenClaw ID tunnel or ID owner-browser enrollment. Gateways with `gateway.roles` configured require identity-aware sign-in and refuse this identity-less code flow; use the Gateway's normal sign-in method instead.

**Ask for a code**

Open the Gateway in any browser and choose **Pair this browser**. The page shows a code such as `ABCD-EFGH` and the command to run.

**Approve it on the host**

```bash
openclaw pair ABCD-EFGH
```

Copy the command from the page: it targets the Gateway that issued the code. A Gateway running under a named profile puts that profile in the code, for example `openclaw pair work:ABCD-EFGH`, and the command selects the `work` profile by itself. A Gateway started with its own `OPENCLAW_STATE_DIR` or `OPENCLAW_CONFIG_PATH` needs the command run with the same setting.

The command prints the browser's user agent, address, page, **Browser ID**, and when it asked, then waits for your answer.

**Let the page connect**

Keep the page open. It connects by itself within a few seconds of approval. Editing the Gateway URL or choosing **Connect** ends the wait, because an approval only works on the Gateway that issued it.

Approval pairs that browser as an operator device with the Control UI's administrator scopes, the same result as approving it with `openclaw devices approve`. It then appears in `openclaw devices list` and the Devices page, where you can remove it. **Only approve a code you requested yourself.** A code is not a secret: it names a waiting browser, and anyone can display one. Running a code someone else sent you gives their browser control of your Gateway, so answer no unless the code in the terminal matches the page in front of you.

Connection interruptions keep the same request and code while the page shows that it is retrying. Approval can still complete during an interruption; the page checks the recorded result when connectivity returns.

**Cancel** withdraws a pending request on the Gateway. The page confirms cancellation only after the Gateway answers, and that code can no longer be approved. If withdrawal cannot be confirmed, retry cancellation. If approval finished first, the page explains that access was already granted and offers **Continue**; cancellation does not revoke an approved device. Remove the browser in Devices to revoke its access. Leaving the page or switching Gateway URLs only stops local waiting and does not claim to withdraw the request.

Codes expire after ten minutes. Only the browser that asked can collect the result, because the Gateway checks the signature of its device key. The device token it receives is bound to that key when the browser signs in over the Gateway WebSocket, but supported HTTP routes accept the token by itself as bearer auth, so treat it as a secret. The page can collect that token again until the code expires, in case a reply was lost; rotating, revoking or removing the device token ends that. A browser that is already paired with a revoked or narrowed operator token keeps that limit, so the code is refused; use the `openclaw dashboard` owner handoff described below, or remove the device first. If you answer no, the page shows that the request was declined.

The page must be served by the Gateway it is connecting to. Pairing also works on plain `http://` LAN addresses, but anyone on that network can read the Gateway traffic afterwards, so prefer HTTPS. See [`openclaw pair`](https://funcoding.ai/agents/openclaw/cli/pair/) for the command's options.

## Pair a mobile device

An already paired administrator can create the iOS/Android connection QR without opening a terminal:

**Open mobile pairing**

Select **Devices**, then click **Connect a device** in the **Devices** card.

**Connect the phone**

In the OpenClaw mobile app, open **Settings** → **Gateway** and scan the QR code. You can copy and paste the setup code instead.

**Confirm the connection**

The official iOS/Android app connects automatically. If **Pending approval** shows a request, review its role and scopes before approving it.

Creating a setup code requires `operator.admin`; **Connect a device** is disabled in the sidebar identity menu and settings for sessions without it. Operators with `operator.pairing` can still review and approve eligible operator-device requests from **Devices**. A setup code contains a short-lived bootstrap credential, so treat the QR and copied code like a password while they are valid. For remote pairing, the Gateway must resolve to `wss://` (for example, through Tailscale Serve/Funnel); plain `ws://` is limited to loopback and private LAN addresses. See [Pairing](https://funcoding.ai/agents/openclaw/channels/pairing/#pair-from-the-control-ui-recommended) for the full security and fallback details.

A new install listens only on its own computer, so no phone can reach it yet. In that case **Connect a device** shows **Set up secure access** instead of a code: [Tailscale Serve](https://funcoding.ai/agents/openclaw/gateway/tailscale/) is recommended, and the trusted-home-network option explains what `gateway.bind lan` opens and how to undo it. The Dashboard does not change your settings. Apply your chosen option on the Gateway host. After restarting the Gateway, wait for the Dashboard to reconnect, reopen **Connect a device**, and choose **Create setup code**.

## Runtime config endpoint

The Control UI fetches its runtime settings from `/control-ui-config.json`, resolved relative to the gateway's Control UI base path (for example `/__openclaw__/control-ui-config.json` under base path `/__openclaw__/`). That endpoint is gated by gateway HTTP auth: unauthenticated browsers cannot fetch it, and a successful fetch requires a valid gateway token/password or trusted-proxy identity. Tailscale header auth applies to the Control UI WebSocket, not this HTTP endpoint.

Local and data-URL agent avatars use [authenticated avatar URLs](https://funcoding.ai/agents/openclaw/web/control-ui/security-model/#avatar-route-auth) in this response and in browser identity RPCs, keeping startup JSON small. Native and CLI RPC clients retain their inline avatar representation.

## PWA install and web push

The Control UI ships a `manifest.webmanifest` and a service worker, so modern browsers can install it as a standalone PWA. Web Push lets the Gateway wake the installed PWA with notifications even when the tab or browser window is not open.

On phones, Chat and New Session share ordinary side gutters inside the device's safe areas. The installed app uses a full standalone canvas; browser tabs follow the dynamic viewport. When the browser reports a keyboard-sized visual viewport reduction, the shell keeps the composer above it and restores the bottom safe area when the keyboard closes, even if the editor still has focus. Pinch zoom remains browser-controlled. Browsers without VisualViewport retain the CSS layout.

Inside the macOS app, the Notifications settings page shows the app's native notification permission instead of browser push because the app delivers notifications natively.

See [Notifications](https://funcoding.ai/agents/openclaw/web/notifications/) for the browser and macOS setup steps.

If the page shows **Protocol mismatch** right after an OpenClaw update, first reopen the dashboard with `openclaw dashboard` and hard-refresh. If it still fails, clear site data for the dashboard origin or test in a private browser window; an old tab or browser service-worker cache can keep running a pre-update Control UI bundle against the newer Gateway.

| Surface                                                                | What it does                                                                |
| ---------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| `ui/public/manifest.webmanifest`                                       | PWA manifest. Browsers offer "Install app" once it is reachable.            |
| `ui/public/sw.js`                                                      | Service worker that handles `push` events and notification clicks.          |
| `state/openclaw.sqlite` → `config_machine_state` (`webPush.vapidKeys`) | Auto-generated VAPID keypair used to sign Web Push payloads.                |
| `state/openclaw.sqlite` → `web_push_subscriptions`                     | Persisted browser endpoints, keys, device/profile bindings, and timestamps. |

Upgrades from the retired `push/vapid-keys.json` and `push/web-push-subscriptions.json` stores are imported by `openclaw doctor --fix`. Stop the Gateway before running that repair so an older process cannot recreate retired state during import. Run the repair before using Web Push after an upgrade; registration, delivery, deletion, and key resolution refuse to proceed while either retired source or an interrupted Doctor claim remains. The Gateway runtime reads and writes SQLite only.

Override the VAPID keypair through env vars on the Gateway process when you want to pin keys (multi-host deployments, secrets rotation, or tests):

- `OPENCLAW_VAPID_PUBLIC_KEY`
- `OPENCLAW_VAPID_PRIVATE_KEY`
- `OPENCLAW_VAPID_SUBJECT` (defaults to `https://openclaw.ai`)

One service-worker registration scope has one browser push subscription and therefore one application-server key. If one installed PWA switches among multiple logical Gateways, configure the same public/private VAPID pair on every Gateway and set each Gateway's `gateway.publicOrigin`; otherwise registration is rejected with a VAPID-identity mismatch. Sharing the private VAPID key and browser endpoint creates one push-signing trust domain, so do this only among mutually trusted Gateways. PWAs installed from separate HTTPS origins or base-path scopes have separate registrations and do not need to share keys.

The Control UI uses these scope-gated Gateway methods to register and test browser subscriptions:

- `push.web.vapidPublicKey` fetches the active VAPID public key.
- `push.web.subscribe` registers an `endpoint` plus `keys.p256dh`/`keys.auth`; the Gateway binds it to the authenticated browser device and current user profile.
- `push.web.unsubscribe` removes a registered endpoint.
- `push.web.test` sends a test notification to registered browser subscriptions.

Pending exec and plugin approvals also trigger Web Push. Approval delivery is narrower than `push.web.test`: the Gateway targets only bound subscriptions whose paired device, current operator token, profile role, and approval visibility still authorize the request. Legacy unbound subscriptions stay test-only until the Control UI reconnects and reconciles them. Push payloads contain generic text and an authenticated `/approve/<approvalId>` link, not approval details.

<div class="callout callout-note">

Web Push is independent of the iOS APNS relay path (see [Configuration](https://funcoding.ai/agents/openclaw/gateway/configuration/) for relay-backed push) and the `push.test` method, which targets native mobile pairing.

</div>

## Tailnet access (recommended)

Keep the Gateway on loopback and let Tailscale Serve proxy it with HTTPS:

```bash
openclaw gateway --tailscale serve
```

Open `https://<magicdns>/` (or your configured `gateway.controlUi.basePath`).

By default, Control UI/WebSocket Serve requests can authenticate via Tailscale identity headers (`tailscale-user-login`) when `gateway.auth.allowTailscale` is `true`. OpenClaw verifies the identity by resolving the `x-forwarded-for` address with `tailscale whois` and matching it to the header, and only accepts these on its dedicated managed-Tailscale listener with Tailscale's `x-forwarded-*` headers. For Control UI operator sessions with browser device identity, this verified Serve path also skips the device-pairing round trip; device-less browsers and node-role connections still follow the normal device checks. Set `gateway.auth.allowTailscale: false` if you want to require explicit shared-secret credentials even for Serve traffic, then use `gateway.auth.mode: "token"` or `"password"`.

For that async Serve identity path, failed auth attempts for the same client IP and auth scope are serialized before rate-limit writes. Concurrent bad retries from the same browser can therefore show `retry later` on the second request instead of two plain mismatches racing in parallel.

<div class="callout callout-warning">

Tokenless Serve auth assumes the gateway host is trusted. If untrusted local code may run on that host, require token/password auth.

</div>

## Insecure HTTP

Opening the dashboard over plain HTTP (`http://<lan-ip>` or `http://<tailscale-ip>`) works: device identity is generated and signed with pure-JS Ed25519, so pairing does not depend on WebCrypto or a secure context. The signing key never leaves the browser, which makes it the one credential a plaintext transport cannot leak — unlike the shared token, which any on-path observer of an HTTP connection can read.

Plain HTTP remains a downgraded transport: an active attacker on the path can modify the page and capture anything in it. Prefer HTTPS wherever possible — Tailscale Serve gives you a real certificate with no configuration — and treat HTTP as a LAN-only convenience. Browsers also withhold secure-context features (for example passkeys) on HTTP, and Chrome's Local Network Access rules increasingly restrict plaintext local requests.

The supported device-less exception is successful operator Control UI auth
through `gateway.auth.mode: "trusted-proxy"`. There is no persistent config
switch that disables device identity.

**Recommended setup:** HTTPS via `https://<magicdns>/` (Tailscale Serve) or the UI locally at `http://127.0.0.1:18789/` (on the gateway host).

<details>
<summary>Trusted-proxy note</summary>

- Successful trusted-proxy auth can admit **operator** Control UI sessions without device identity.
- This does **not** extend to node-role Control UI sessions.
- A same-host loopback reverse proxy requires both loopback in `gateway.trustedProxies` and `gateway.auth.trustedProxy.allowLoopback: true`; see [Trusted proxy auth](https://funcoding.ai/agents/openclaw/gateway/trusted-proxy-auth/).

</details>

See [Tailscale](https://funcoding.ai/agents/openclaw/gateway/tailscale/) for HTTPS setup guidance.

## Blank Control UI page

Browsers without module-script support show **This browser is not supported**. Open the Control UI in an up-to-date browser, or update your system WebView.

If the browser loads a blank dashboard and DevTools shows no useful error, an extension or early content script may have prevented the JavaScript module app from evaluating. The static page includes a plain HTML recovery panel that appears when `<openclaw-app>` does not complete its first render after startup. While the browser is still downloading the initial app modules, the panel shows **Control UI is still loading** and leaves those downloads running. Once module loading finishes without a render, automatic recovery can request a fresh page. **Keep waiting** cancels a pending recovery request and gives the current page more time; **Try again** explicitly reloads it.

Use the panel's **Try again** action after changing the browser environment, or reload manually after these checks:

- Disable extensions that inject into all pages, especially extensions with `<all_urls>` content scripts.
- Try a private window, a clean browser profile, or another browser.
- Keep the Gateway running and verify the same dashboard URL after the browser change.
