skip to content

After you edit openclaw.json, why do some OpenClaw Gateway changes apply live while others restart the process, and when do you run openclaw gateway restart yourself?

level: seniorimportance: should knowfreq 8%

answer

  1. the Gateway watches its config file
  2. default reload mode
  3. hot, restart or none per path
  4. server settings like port and bind
  5. installed service remembers its port

basics

~20 s

Under the default hybrid reload mode, the Gateway classifies each changed config path: agents, models, sessions and tools apply live, while port, bind, auth mode and TLS restart it automatically. Restart by hand in off mode or after changing an installed service's port.

solid answer

~50 s

The Gateway watches its active config file and swaps an in-memory snapshot when an edit validates. Under the default `gateway.reload.mode` of `hybrid`, reload planning classifies each changed path as `hot`, `restart` or `none` by its longest matching prefix: `agents`, `models`, `session`, `tools` and `bindings` apply live, `hooks` and `cron` reload their own subsystem, and other `gateway.*` settings such as port, bind, auth mode, Tailscale and TLS restart the process automatically; an unmatched path also restarts. An invalid edit is skipped with `config reload skipped (invalid config)` and the last good config keeps running. You run `openclaw gateway restart` yourself when the mode is `off`, and after changing `gateway.port` on an installed service you run `openclaw doctor --fix` or `openclaw gateway install --force`, because the service records its `--port`. Prefer `restart --safe` to let active work drain.

code

bash · 12 lines
bash
# check the hand edit before trusting it
openclaw config validate

# repair legacy keys, rewrite the service's recorded --port
openclaw doctor --fix

# restart once active work drains (forced after 5 minutes)
openclaw gateway restart --safe

# confirm it came back and watch the reload lines
openclaw gateway status
openclaw logs --follow

go deeper

for a junior

Recall that the Gateway reloads its config file by itself under the default hybrid mode, and that some server settings make it restart.

for a middle

Explain the hot, restart and none outcomes, the longest-prefix rule, and which families of settings land in each, with gateway port, bind and TLS as restart cases.

for a senior

Show the operational traps: invalid edits silently kept out, the installed service's recorded port, off mode waiting for you, and safe restarts that let active work drain.

for a principal

Decide how a team changes a live Gateway: who edits by hand versus through the Gateway, when to run with reload off, and how restarts are scheduled around active work.

## The Gateway watches its own config A running OpenClaw Gateway watches its active config file: `~/.openclaw/openclaw.json` by default, the profile's file under a named profile, or `OPENCLAW_CONFIG_PATH` when set. After the first successful load it serves an in-memory **config snapshot**, and every accepted change swaps that snapshot atomically. Edits written through the Gateway itself, for example by `config.set`, are published directly; hand edits are picked up by the file watcher once the editor's temp-write and rename churn settles. ## Reload modes `gateway.reload.mode` decides what happens next: | Mode | Behaviour | | --- | --- | | `hybrid` (default) | Applies hot-reloadable settings live and restarts the Gateway automatically when a change requires it. | | `off` | Keeps watching and validating the file; passive runtime changes wait for a manual restart. Explicit plugin lifecycle actions still apply. | In OpenClaw 2026.9.9 these are the only two values. The earlier `hot` and `restart` modes were retired in `v2026.7.2-beta.4`, stable from `v2026.8.1`, and `openclaw doctor --fix` maps either of them to `hybrid`. ## How a change is classified Reload planning looks at each changed config path and assigns one outcome: - **`restart`** - the whole Gateway process restarts. - **`hot`** - applied while the process keeps running, which may mean restarting just the owning subsystem: a channel, cron or heartbeat. - **`none`** - the snapshot updates and consumers see the new value on their next read. The **longest matching config prefix** decides, and a path that matches no rule defaults to a Gateway restart. Some representative rows: | Change | Gateway restart? | | --- | --- | | `agents`, `models`, `session`, `messages`, `tools`, `skills`, `bindings` | No | | `hooks`, `cron`, `agents.defaults.heartbeat` | No; the owning subsystem reloads | | `channels.*` | Depends on the setting and the channel plugin | | `gateway.auth.token` with the same auth mode | No; old shared-auth clients reconnect | | Other `gateway.*`: port, bind, auth mode, Tailscale, TLS | Yes | So an agent's model change lands without dropping any connection, while a `gateway.bind` change makes the Gateway restart itself; its admission-close log names the trigger, for example `restart (SIGUSR2: config reload: gateway.bind)`. ## When an edit is invalid Direct edits are untrusted until they validate. An invalid hot reload is skipped and the Gateway keeps the last accepted config; the log shows `config reload skipped (invalid config)`. The Gateway keeps a last-known-good copy after each successful startup, but startup and hot reload never restore it themselves. The fix is: 1. `openclaw config validate` to see what is wrong. 2. `openclaw doctor --fix` to repair what it can, including legacy key migrations. 3. A restart, if the repaired change is restart-class. Clients can tell whether a saved config is actually live by comparing the snapshot's `appliedConfigHash` with `config.get.configRevisionHash`. ## Reading what the reload did - **Each accepted revision is logged**, together with whether it came from a Gateway write or a file edit, so `openclaw logs --follow` shows which source won. - **A busy state store delays, not drops, a change.** If the reload cannot get its lifecycle lease, the change stays pending and retries with a capped backoff; the previous runtime stays active meanwhile, and no second edit is needed. - **Some hot changes still bounce a subsystem.** Changing `agents.defaults.mediaMaxMb`, for example, restarts the channel runtimes so their attachment limits change together, while the Gateway process keeps running. ## When you restart it yourself Most edits need no manual restart under `hybrid`. You run `openclaw gateway restart` when: - `gateway.reload.mode` is `off` and a passive change is waiting. - You changed `gateway.port` on an **installed service**. The service records the resolved `--port` in its supervisor metadata, and `--port` outranks `gateway.port`, so run `openclaw doctor --fix` or `openclaw gateway install --force` to rewrite it; a plain restart alone would come back on the recorded port. - Something is wedged and `openclaw gateway status` or `openclaw logs --follow` points at the process itself. The restart command has a few useful shapes: - `openclaw gateway restart --safe` preflights active work and restarts once it drains, forcing the restart after at most five minutes. - `openclaw gateway restart --wait 30s` sets the drain budget for a plain restart. - `openclaw gateway restart --force` starts at once and cancels only work still running at the deadline. Use the restart command rather than chaining `openclaw gateway stop` and `openclaw gateway start`. Scripts that signal the process must send `SIGUSR2`; `SIGUSR1` now starts Node's inspector instead of restarting. A restart drops every WebSocket client, which reconnects, and an interrupted agent turn is resumed automatically where possible.

  • Why might an OpenClaw Gateway service come back on its old port after you change gateway.port?
    An installed service records the resolved `--port` in its launchd, systemd or Scheduled Tasks metadata, and `--port` outranks `gateway.port` in the resolution order. Run `openclaw doctor --fix` or `openclaw gateway install --force` so the service definition is rewritten with the new port.
  • What does openclaw gateway restart --safe do differently from a plain restart?
    It asks the running Gateway to preflight active work and schedule one coalesced restart after that work drains, with the wait bounded to five minutes before the restart is forced. It cannot be combined with `--force` or `--wait`; add `--skip-deferral` only when a runaway task is holding the deferral.

  • Every edit to openclaw.json needs openclaw gateway restart before it takes effect.
  • Setting gateway.reload.mode to hot avoids restarts for port and bind changes.
  • An invalid edit crashes the running Gateway until the file is fixed.
  • The Gateway restores openclaw.json from its backup ring when a reload fails.
  • Stopping and then starting the Gateway is the same as openclaw gateway restart.

Assumes OpenClaw 2026.9.9; gateway.reload.mode accepts only hybrid and off since the hot and restart modes were retired in v2026.7.2-beta.4, stable from v2026.8.1.