Where Is the OpenClaw Config File?
OpenClaw keeps its configuration in a single JSON5 file at ~/.openclaw/openclaw.json on every OS. This guide shows how to find the active file, edit it without breaking the gateway, regenerate it from scratch, and which fields not to touch.
You need to change a model, add a channel, or fix a setting the docs mention, but you cannot find where OpenClaw actually keeps its configuration. The answer is short, and the details around it (how to edit safely, what happens when you break it, which fields bite back) are worth two minutes of your time before you open an editor.
The Short Answer: ~/.openclaw/openclaw.json
OpenClaw reads a single optional config file from a hidden .openclaw folder in your home directory:
- macOS:
/Users/<you>/.openclaw/openclaw.json - Linux:
/home/<you>/.openclaw/openclaw.json - Windows:
C:\Users\<you>\.openclaw\openclaw.json(that is%USERPROFILE%\.openclaw\openclaw.json)
The file is JSON5, not strict JSON, so comments and trailing commas are allowed. If the file does not exist at all, OpenClaw simply runs with safe defaults; it is created and filled in during onboarding.
Find the Active Config File in One Command
Do not guess the path, ask OpenClaw. The CLI prints the exact file the gateway is using:
openclaw config file
Two situations where the answer differs from the default location:
- The
OPENCLAW_CONFIG_PATHenvironment variable overrides the default. If someone set it (common in Docker or systemd setups), the active file lives wherever it points. Check withecho $OPENCLAW_CONFIG_PATHon macOS and Linux orecho $env:OPENCLAW_CONFIG_PATHin PowerShell. - On a server, the config belongs to the user running the gateway. If OpenClaw runs under a service account, look in that account's home directory, not yours.
How to View and Edit the Config Safely
You have four editing routes, from safest to most manual:
- Back up first. One command spares you a bad afternoon:
cp ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.bak - Read a value without opening the file:
openclaw config get agents.defaults.model - Set a value through the CLI so the syntax stays valid:
openclaw config set gateway.port 18790 - Edit the file directly in any editor. The gateway watches the file and hot-reloads safe changes automatically, so you usually do not need a manual restart.
- Use the Control UI at
http://127.0.0.1:18789, which has a Config tab with the same settings in a form.
After any manual edit, validate before you walk away:
openclaw config validate
OpenClaw uses strict schema validation: unknown keys, wrong types, or invalid values make the gateway refuse to start. The safety nets are good, though. Invalid edits get saved aside as openclaw.json.rejected.<timestamp> for inspection, and the gateway keeps a trusted last-known-good copy from its last successful start.
How to Regenerate the Config From Scratch
If the file is mangled beyond repair, you do not need to reinstall OpenClaw.
- Move the broken file out of the way:
mv ~/.openclaw/openclaw.json ~/.openclaw/openclaw.json.broken - Run the interactive setup to build a fresh one:
openclaw configure(or the fulleropenclaw onboardflow). - Restart and confirm:
openclaw gateway restart, thenopenclaw gateway status. - Copy any custom sections you still need from the broken file back in, one block at a time, validating after each paste.
What NOT to Touch
A few fields cause a disproportionate share of broken gateways:
- The model field expects a string. Set
agents.defaults.modelto a plain provider/model string such as"anthropic/claude-opus-4-8". Pasting a nested object where a string belongs fails validation, and there are reports of an invalid model config leaving the gateway spinning at high CPU instead of exiting cleanly. If you need fallbacks, use the documented structured form exactly, and validate afterwards. - Do not invent keys. The schema is strict, so a guessed setting name does not get ignored, it blocks startup. Check
openclaw config getfor the real key first. - Do not symlink the config file. OpenClaw writes the file atomically by renaming a new file onto the path, which replaces a symlink's target instead of writing through it. Keep the real file at the real path, or use
OPENCLAW_CONFIG_PATHif you want it elsewhere. - Treat secrets as secrets. The file can contain gateway auth tokens and API keys. Do not commit it to git or paste it whole into chat or forums; redact before sharing.
Frequently Asked Questions
Can I move the OpenClaw config file somewhere else?
Yes. Set the OPENCLAW_CONFIG_PATH environment variable to the full path of the real file and restart the gateway. This is the supported way to keep config in a custom location, for example on a mounted volume. Point it at a regular file, not a symlink.
What format is openclaw.json? My editor flags the comments as errors.
It is JSON5, a superset of JSON that allows comments, trailing commas, and unquoted keys. Editors linting it as plain JSON will complain incorrectly. Either switch the file type to JSON5 in your editor or ignore those specific warnings; openclaw config validate is the verdict that actually matters.
I broke the config and the gateway will not start. Now what?
Run openclaw doctor to see the exact complaint. Look for an openclaw.json.rejected file next to your config, which holds the edit that failed validation. Then either restore your backup, fix the flagged line, or regenerate with openclaw configure. Your sessions and pairing data live in separate files, so fixing the config does not erase them.
On a managed OpenClaw host, the config ships pre-validated and stays that way through updates, so this file is one you rarely have to open.
Frequently asked questions
- Can I move the OpenClaw config file somewhere else?
- Yes. Set the OPENCLAW_CONFIG_PATH environment variable to the full path of the real file and restart the gateway. This is the supported way to keep config in a custom location, for example on a mounted volume. Point it at a regular file, not a symlink.
- What format is openclaw.json? My editor flags the comments as errors.
- It is JSON5, a superset of JSON that allows comments, trailing commas, and unquoted keys. Editors linting it as plain JSON will complain incorrectly. Either switch the file type to JSON5 in your editor or ignore those specific warnings; openclaw config validate is the verdict that actually matters.
- I broke the config and the gateway will not start. Now what?
- Run openclaw doctor to see the exact complaint. Look for an openclaw.json.rejected file next to your config, which holds the edit that failed validation. Then either restore your backup, fix the flagged line, or regenerate with openclaw configure. Your sessions and pairing data live in separate files, so fixing the config does not erase them.
Related guides
- OpenClaw Gateway "Maximum Call Stack Size Exceeded"? Here Is the FixThe RangeError: Maximum call stack size exceeded crash in the OpenClaw Gateway has three known causes: a config recursion bug around disabled plugins, version-specific schema compilation bugs, and oversized session payloads. This guide walks through each fix with exact commands.
- OpenClaw: Command Not Found? Fix Your PATH in 5 MinutesThe "openclaw: command not found" error almost always means npm's global bin directory is not on your shell's PATH. This guide gives the exact fix for macOS zsh, Linux bash, and Windows, plus the nvm gotcha that silently removes the command.
- OpenClaw Stuck on Starting (or the Control Panel Will Not Open)When OpenClaw hangs on startup it is almost always a port conflict, a broken config file, the wrong Node version, or a service manager hiding an interactive prompt. When the gateway runs but the control panel will not open, an expired dashboard token or a blocked port is the usual cause. This guide covers every fix with exact commands.
- Fixing "API rate limit reached, please try again" in OpenClawThis error means your model provider returned a 429, not that OpenClaw is broken. Learn what the limit means on Anthropic, OpenAI, and Groq, how OpenClaw's cooldown and fallback logic behaves, and how to configure fallbacks so one throttled key never stops your agent.
