When a host runs a second OpenClaw Gateway as a rescue bot, what must each instance own separately so the rescue lane survives the main one breaking, and how do you prove it does?
answer
- nothing shared that can fail together
- own bot token for the rescue bot
- rescue bot on its own profile
- config, state, workspace, port
- 120 ports apart
basics
~20 sEach instance needs its own --profile, config path, state directory, workspace, channel credentials and a base port at least 120 away, since startup refuses shared state. Prove it with gateway status --deep on both profiles, gateway probe, and a test with the main Gateway stopped.
solid answer
~40 sA rescue bot exists to diagnose and repair config while the main Gateway is down, so it must share nothing that can fail with the main one. Run it under a named `--profile`, which moves its config and state under `~/.openclaw-<name>` and gives its service its own name, and keep `OPENCLAW_CONFIG_PATH`, `OPENCLAW_STATE_DIR`, `agents.defaults.workspace` and `gateway.port` unique, with base ports at least 120 apart for the derived browser ports. Give it its own channel credentials, such as a separate Telegram bot token. Startup refuses shared state even with `OPENCLAW_ALLOW_MULTI_GATEWAY=1`. Verify with `openclaw gateway status --deep` for each profile and `openclaw gateway probe`, then stop the main Gateway and check the rescue bot still answers.
go deeper
Recall that one Gateway per machine is the normal setup, and that a second one such as a rescue bot runs under its own profile and port.
Explain the isolation checklist for a second instance: profile, config path, state directory, workspace and base port, and why ports need spacing.
Show how a second instance is set up and verified, and the traps: state directory without a profile, shared credentials, competing services found by status --deep.
Design the rescue lane so nothing it depends on can fail with the main Gateway: its own profile, state, port range, service and credentials, proven by a stopped-main test rather than two green status checks.
## Why the rescue lane has to stand alone OpenClaw's own guidance is that most installs run **one Gateway per machine**; whether a second one is worth its cost is a separate call, made against what agents inside one Gateway can already do. This question starts after that call. The usual second instance is a small **rescue bot** on its own profile, port and Telegram bot token, which can still diagnose and repair config when the main Gateway is down. It is only useful if nothing the main Gateway depends on can take it down too. ## What sharing would break - **A shared config file.** The bad edit that stops the main Gateway stops the rescue one as well. - **A shared state directory.** Startup enforces one owner per state directory, so the rescue instance waits and then fails with a lock error. - **Shared channel credentials.** Two instances on one login fight over the connection, and the rescue bot is unreachable when you need it. - **A shared service.** Without its own profile, an install or restart lands on the default service. - **Overlapping derived ports.** Browser control and CDP ports collide when the base ports sit closer than the guide allows, even though the base ports differ. ## What each instance must own Run the extra Gateway under a **named profile**, which moves its state and config under `~/.openclaw-<name>`, and keep these unique per instance: | Setting | Why it must differ | | --- | --- | | `OPENCLAW_CONFIG_PATH` | each instance reads its own config | | `OPENCLAW_STATE_DIR` | sessions, credentials and caches; startup enforces exclusive ownership | | `agents.defaults.workspace` | each instance's agent files stay apart | | `gateway.port` or `--port` | the listener is an exclusive bind | | derived browser and CDP ports | they sit from base + 2 up to base + 110 | The derived ports are why the guide asks for **at least 120 ports between base ports**, for example `18789` for the main Gateway and `19789` for the rescue one. ## How to set it up and check it 1. Onboard the extra instance under its profile: `openclaw --profile rescue onboard`, or `openclaw --profile ops setup` for a general second Gateway. 2. Install its service on its own port: `openclaw --profile rescue gateway install --port 19789`. Service names follow the profile, giving labels such as `ai.openclaw.rescue`. 3. Check both: `openclaw gateway status --deep` and `openclaw --profile rescue gateway status --deep` catch stale or competing services, and `openclaw gateway probe` warns about `multiple reachable gateway identities`, which is expected when you meant to run two. ## Traps a lead should catch in review - **`OPENCLAW_STATE_DIR` alone is not isolation for a managed service.** Service names follow the profile, not the state directory, and the docs warn never to install or restart the default service against a temporary state directory. - **`OPENCLAW_ALLOW_MULTI_GATEWAY=1` does not allow shared state.** Startup still refuses a second owner of the same state directory and eventually fails with a `GatewayLockError`. - **Shared credentials.** Give each instance its own channel credentials, as the rescue guide does with a separate Telegram bot token, so the two never fight over one account. - **A second profile mistaken for a security boundary.** Processes under one OS user can generally reach each other's files; the profile separates operations, not people. ## Proving the lane before you need it Two green status checks show two healthy processes, not an independent rescue lane. The test that matters is the failure the lane exists for: stop the main Gateway with `openclaw gateway stop`, message the rescue bot on its own channel, and confirm it answers and can reach the main install's files to diagnose them. Repeat the check after upgrades and after any change to either profile's config, ports or credentials, because each of those is a new way for the two to start sharing something.
- Why does the OpenClaw multiple-gateway guide ask for at least 120 ports between base ports?Each Gateway derives more ports from its base: the browser control port at base + 2 and a browser CDP range that runs to base + 110. Base ports closer than that let one instance's derived ports collide with the other's. If you override any derived port, you must keep it unique per instance yourself.
- Why is a rescue OpenClaw Gateway that reads the main instance's config file no rescue at all?The rescue bot exists for the moment the main Gateway's config is broken. If both instances load the same config, the edit that stops the main one stops the rescue one too, so nothing is left to diagnose or repair it. A named profile gives the rescue instance its own config path, state directory and service.
- A rescue Gateway can share the main one's config file as long as it uses another port.
- Setting OPENCLAW_STATE_DIR is enough to isolate a second managed Gateway service.
- OPENCLAW_ALLOW_MULTI_GATEWAY=1 lets two Gateways share one state directory.
- Two Gateways under one OS user cannot reach each other's files.
- Any two different ports are fine for two Gateways on one host.