troubleshooting

Fix: OpenClaw Permission Errors

Solve file and directory permission issues when installing or running OpenClaw on Linux and macOS.

5 min read
Updated 2026-02-03

The Problem

You see errors like:

EACCES: permission denied

Or:

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'

Or:

Permission denied: ~/.openclaw/config.yaml

What This Means

Your user account does not have permission to read or write to certain files or directories. This is common on Linux and macOS, especially when installing global npm packages.


Quick Fix for npm Installation Errors

If you see permission errors during npm install -g openclaw:

This is the safest and best long-term solution.

Create a directory for global packages:

bash

mkdir -p ~/.npm-global

Configure npm to use this directory:

bash

npm config set prefix '~/.npm-global'

Add to your PATH:

For bash (most Linux and older macOS):

bash

echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc source ~/.bashrc

For zsh (newer macOS):

bash

echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc source ~/.zshrc

Now install OpenClaw:

bash

npm install -g openclaw

Not Recommended for Regular Use

Using sudo for npm can cause more permission problems later. Use Option 1 if possible.

bash

sudo npm install -g openclaw


Permission Errors with OpenClaw Config Directory

If you see errors about ~/.openclaw/:

Check Current Permissions

bash

ls -la ~/.openclaw

Expected Result

drwxr-xr-x user user .openclaw -rw-r--r-- user user config.yaml -rw------- user user auth-profiles.json

The owner should be your username, not root.

Fix Ownership

bash

sudo chown -R $(whoami) ~/.openclaw

Fix Permission Mode

bash

chmod -R u+rw ~/.openclaw chmod 600 ~/.openclaw/auth-profiles.json

The auth-profiles.json should have restricted permissions (600) since it contains sensitive data.


Permission Errors with npm Cache

If you see errors about the npm cache:

bash

sudo chown -R $(whoami) ~/.npm


Permission Errors on macOS

Homebrew Permissions

If Homebrew has permission issues:

bash

sudo chown -R $(whoami) /usr/local/Cellar sudo chown -R $(whoami) /usr/local/Homebrew

Apple Silicon (M1/M2/M3) Macs

On newer Macs, Homebrew installs to /opt/homebrew/:

bash

sudo chown -R $(whoami) /opt/homebrew


Permission Errors on Linux

Global Node Modules

If /usr/local/lib/node_modules has permission issues:

Option 1: Change ownership (simple):

bash

sudo chown -R $(whoami) /usr/local/lib/node_modules

Option 2: Use npm prefix (better):

See the "Quick Fix" section above for setting up ~/.npm-global.

Systemd Service Permissions

If the daemon cannot start:

bash

Check the service status

systemctl --user status openclaw

Check logs for permission errors

journalctl --user -u openclaw -n 50

Fix user service directory:

bash

mkdir -p ~/.config/systemd/user chmod 755 ~/.config/systemd/user

/tmp Permission Issues

If OpenClaw has trouble with temporary files:

bash

Check /tmp permissions

ls -la /tmp

Should show: drwxrwxrwt

The 't' (sticky bit) is important


Common Scenarios

Scenario 1: Installed with sudo, Now Getting Errors

If you previously used sudo npm install and now have permission problems:

bash

Fix npm directory

sudo chown -R $(whoami) ~/.npm

Fix global modules (if you own them)

sudo chown -R $(whoami) /usr/local/lib/node_modules/openclaw

Fix OpenClaw config

sudo chown -R $(whoami) ~/.openclaw

Scenario 2: Multiple Users on Same Computer

If multiple users need OpenClaw, each should:

  1. Have their own ~/.openclaw directory
  2. Install OpenClaw in their own npm prefix

Or use Docker for isolation.

Scenario 3: Running as Root

Do Not Run as Root

Running OpenClaw as root is a security risk. Always run it as a regular user.

If you accidentally ran something as root:

bash

Fix ownership

sudo chown -R $(whoami) ~/.openclaw sudo chown -R $(whoami) ~/.npm


Checking Permissions

Understanding Permission Notation

When you run ls -la, permissions look like: -rw-r--r--

  • Position 1 - File type (- = file, d = directory)

  • Position 2-4 - Owner permissions (rwx)

  • Position 5-7 - Group permissions (rwx)

  • Position 8-10 - Others permissions (rwx)

  • r = read

  • w = write

  • x = execute (or access for directories)

  • ~/.openclaw/ - Permission 755 → chmod 755 ~/.openclaw
  • config.yaml - Permission 644 → chmod 644 ~/.openclaw/config.yaml
  • auth-profiles.json - Permission 600 → chmod 600 ~/.openclaw/auth-profiles.json
  • Channel tokens - Permission 600 → chmod 600 ~/.openclaw/channels/*

Security Audit

Run the built-in security check:

bash

openclaw security audit --deep

This will warn you about permission issues.


Prevention Tips

  1. Never use sudo with npm for package installation unless absolutely necessary

  2. Set up npm prefix correctly from the start (see Quick Fix above)

  3. Check ownership after system updates as updates can sometimes change permissions

  4. Use a dedicated user for running OpenClaw on servers

  5. Regular security audits:

bash

openclaw security audit


Docker Alternative

If permission issues persist, consider using Docker:

bash

docker run -d --name openclaw
-v openclaw_data:/root/.openclaw
-p 18789:18789
openclaw:local

Docker handles permissions within the container, avoiding most host permission issues.

See: Install OpenClaw with Docker


Still Having Issues?

  1. Gather diagnostic information:
bash

ls -la ~/.openclaw ls -la ~/.npm id whoami

  1. Check the logs:
bash

openclaw logs --limit 50

  1. Try a fresh install with correct permissions:
bash

Remove old installation

sudo npm uninstall -g openclaw rm -rf ~/.openclaw

Set up npm correctly

mkdir -p ~/.npm-global npm config set prefix '~/.npm-global' export PATH=~/.npm-global/bin:$PATH

Fresh install

npm install -g openclaw openclaw onboard


Need Help?

If you run into problems not covered here, check our Troubleshooting guide or visit the official OpenClaw documentation.

Last updated: February 3, 2026 | Found an error? Contact us

Related Articles