2026-01-15 07:29:48 +00:00
---
2026-01-30 03:15:10 +01:00
summary: "Run multiple OpenClaw Gateways on one host (isolation, ports, and profiles)"
2026-01-15 07:29:48 +00:00
read_when:
- Running more than one Gateway on the same machine
- You need isolated config/state/ports per Gateway
2026-01-31 16:04:03 -05:00
title: "Multiple Gateways"
2026-01-15 07:29:48 +00:00
---
2026-01-31 21:13:13 +09:00
2026-01-15 07:29:48 +00:00
# Multiple Gateways (same host)
2026-01-15 18:08:20 +01:00
Most setups should use one Gateway because a single Gateway can handle multiple messaging connections and agents. If you need stronger isolation or redundancy (e.g., a rescue bot), run separate Gateways with isolated profiles/ports.
2026-01-15 07:29:48 +00:00
## Isolation checklist (required)
2026-01-31 21:13:13 +09:00
2026-01-30 03:15:10 +01:00
- `OPENCLAW_CONFIG_PATH` — per-instance config file
- `OPENCLAW_STATE_DIR` — per-instance sessions, creds, caches
2026-01-15 07:29:48 +00:00
- `agents.defaults.workspace` — per-instance workspace root
- `gateway.port` (or `--port` ) — unique per instance
2026-01-22 23:07:58 +00:00
- Derived ports (browser/canvas) must not overlap
2026-01-15 07:29:48 +00:00
If these are shared, you will hit config races and port conflicts.
## Recommended: profiles (`--profile`)
2026-01-30 03:15:10 +01:00
Profiles auto-scope `OPENCLAW_STATE_DIR` + `OPENCLAW_CONFIG_PATH` and suffix service names.
2026-01-15 07:29:48 +00:00
```bash
# main
2026-01-30 03:15:10 +01:00
openclaw --profile main setup
openclaw --profile main gateway --port 18789
2026-01-15 07:29:48 +00:00
# rescue
2026-01-30 03:15:10 +01:00
openclaw --profile rescue setup
openclaw --profile rescue gateway --port 19001
2026-01-15 07:29:48 +00:00
```
2026-01-21 17:45:12 +00:00
Per-profile services:
2026-01-31 21:13:13 +09:00
2026-01-15 07:29:48 +00:00
```bash
2026-01-30 03:15:10 +01:00
openclaw --profile main gateway install
openclaw --profile rescue gateway install
2026-01-15 07:29:48 +00:00
```
2026-01-15 18:08:20 +01:00
## Rescue-bot guide
Run a second Gateway on the same host with its own:
2026-01-31 21:13:13 +09:00
2026-01-15 18:08:20 +01:00
- profile/config
- state dir
- workspace
- base port (plus derived ports)
This keeps the rescue bot isolated from the main bot so it can debug or apply config changes if the primary bot is down.
2026-01-22 23:07:58 +00:00
Port spacing: leave at least 20 ports between base ports so the derived browser/canvas/CDP ports never collide.
2026-01-15 18:08:20 +01:00
### How to install (rescue bot)
```bash
# Main bot (existing or fresh, without --profile param)
2026-01-31 21:13:13 +09:00
# Runs on port 18789 + Chrome CDC/Canvas/... Ports
2026-01-30 03:15:10 +01:00
openclaw onboard
openclaw gateway install
2026-01-15 18:08:20 +01:00
# Rescue bot (isolated profile + ports)
2026-01-30 03:15:10 +01:00
openclaw --profile rescue onboard
2026-01-31 21:13:13 +09:00
# Notes:
2026-01-15 18:08:20 +01:00
# - workspace name will be postfixed with -rescue per default
2026-01-31 21:13:13 +09:00
# - Port should be at least 18789 + 20 Ports,
2026-01-15 18:08:20 +01:00
# better choose completely different base port, like 19789,
# - rest of the onboarding is the same as normal
2026-01-21 17:45:12 +00:00
# To install the service (if not happened automatically during onboarding)
2026-01-30 03:15:10 +01:00
openclaw --profile rescue gateway install
2026-01-15 18:08:20 +01:00
```
2026-01-15 07:29:48 +00:00
## Port mapping (derived)
2026-01-30 03:15:10 +01:00
Base port = `gateway.port` (or `OPENCLAW_GATEWAY_PORT` / `--port` ).
2026-01-15 07:29:48 +00:00
2026-01-27 03:23:42 +00:00
- browser control service port = base + 2 (loopback only)
2026-02-14 14:55:10 +01:00
- canvas host is served on the Gateway HTTP server (same port as `gateway.port` )
2026-01-15 07:29:48 +00:00
- Browser profile CDP ports auto-allocate from `browser.controlPort + 9 .. + 108`
If you override any of these in config or env, you must keep them unique per instance.
## Browser/CDP notes (common footgun)
2026-01-27 03:23:42 +00:00
- Do **not** pin `browser.cdpUrl` to the same values on multiple instances.
- Each instance needs its own browser control port and CDP range (derived from its gateway port).
2026-01-15 07:29:48 +00:00
- If you need explicit CDP ports, set `browser.profiles.<name>.cdpPort` per instance.
- Remote Chrome: use `browser.profiles.<name>.cdpUrl` (per profile, per instance).
## Manual env example
```bash
2026-01-30 03:15:10 +01:00
OPENCLAW_CONFIG_PATH=~/.openclaw/main.json \
OPENCLAW_STATE_DIR=~/.openclaw-main \
openclaw gateway --port 18789
2026-01-15 07:29:48 +00:00
2026-01-30 03:15:10 +01:00
OPENCLAW_CONFIG_PATH=~/.openclaw/rescue.json \
OPENCLAW_STATE_DIR=~/.openclaw-rescue \
openclaw gateway --port 19001
2026-01-15 07:29:48 +00:00
```
## Quick checks
```bash
2026-01-30 03:15:10 +01:00
openclaw --profile main status
openclaw --profile rescue status
openclaw --profile rescue browser status
2026-01-15 07:29:48 +00:00
```