Intermediate
macOS / Linux / Windows (WSL2) / Docker / Self-hosted
Estimated time: 25 min

OpenClaw State, Workspace, and Memory: Persistence & Permissions Troubleshooting

Fix 'memory not written', 'it said it saved files but nothing exists', and post-restart amnesia by understanding the state directory, workspace paths, container UID/GID, and how to make persistence reproducible across Docker/VPS/PaaS.

Implementation Steps

Most 'I lost memory/tokens' reports are the state directory being wiped or not mounted where you think.

If OpenClaw:

  • “forgets everything” after a restart/redeploy,
  • never writes memory files,
  • or claims it saved files but the directory is empty,

you’re almost always dealing with persistence (wrong directory / wiped disk) or permissions (can’t write).

This guide helps you validate the real on-disk paths and make them stable.

Related (high value):


0) The two directories that matter

A) State directory (must persist)

Default: ~/.openclaw/ (unless overridden by OPENCLAW_STATE_DIR).

It commonly contains:

  • openclaw.json (config)
  • credentials/tokens
  • device approvals (Control UI pairing)
  • cron job state
  • caches and internal DBs

If this directory is wiped, you didn’t “lose a token” — you created a new machine.

B) Workspace directory (must exist + be writable)

This is where tools and runs write artifacts (reports, downloads, generated files). If the workspace path points to a nonexistent or unwritable directory, you’ll see “it said it wrote a file” but nothing appears.

Where it’s configured varies by version, but you can always confirm the effective value via CLI:

openclaw config get agents.defaults.workspace

If you’re on Docker, also check any workspace env var you set (for example OPENCLAW_WORKSPACE_DIR) and make sure it matches the container path.


1) Confirm what the running gateway is actually using

The #1 footgun is editing the wrong config file or assuming your interactive shell env is what the service uses.

Use:

openclaw status --deep
openclaw doctor

Then re-check config precedence:


2) Fix the most common “can’t write” failures

2.1 Docker: bind-mounted ~/.openclaw not writable (UID/GID mismatch)

Symptoms:

  • errors like EACCES: permission denied ... openclaw.json.*.tmp
  • config changes don’t persist
  • workspace artifacts never appear

Fix page:

2.2 Unsafe temp dir /tmp permission issues

If OpenClaw refuses to start with an “unsafe fallback temp dir” error, fix temp directory ownership/permissions:


3) Fix the most common “it forgets after restart” failures

3.1 You did not persist the state directory

If you are on:

  • Docker → you must mount a host volume for the state directory
  • VPS/PaaS → avoid ephemeral root disks / container layers

Use the persistence playbook:

3.2 You have multiple installs and the service uses a different runtime

This is especially common when the shell you used for install is not the same environment the running service actually uses. On native Windows, that mismatch can look like PATH drift, Scheduled Task drift, or “ghost writes” to the wrong home/state path. For that path specifically, also see:

If updates/installs were done in one shell, but the daemon runs another Node/PATH, you can get inconsistent behavior and “ghost writes” (writes go to a different home/state than you think).

Start here:


4) A persistence verification drill (do once)

  1. Create a timestamped artifact in the workspace (via a tool/run or manually).
  2. Restart the gateway service.
  3. Verify the artifact still exists on disk.

If you also rely on Control UI:

If you rely on cron:


5) Backup strategy (minimum viable)

Back up the entire state directory as a unit, not “just openclaw.json”.

CoClaw checklist:

Verification & references

  • Reviewed by:CoClaw Editorial Team
  • Last reviewed:March 14, 2026
  • Verified on: macOS · Linux · Windows (WSL2) · Docker · Self-hosted

Related Resources

Need live assistance?

Ask in the community forum or Discord support channels.

Get Support