Errors / Unauthorized

Fix: Unauthorized

Error: "unauthorized", "401 Unauthorized", "authentication failed"

What It Means

The gateway rejected your connection because authentication failed. The token you're using doesn't match what the gateway expects, or no token was provided when one is required.

Common Causes

  • Gateway requires a token but none was provided
  • Token in your client doesn't match the gateway's token
  • Token was changed but client still has old one
  • Using WebChat without passing the token in the URL

Ask Your Agent to Fix This

Copy this prompt and send it to your OpenClaw agent:

Check my gateway auth configuration. Make sure the auth token is set correctly and matches what's being used by my client. If there's a mismatch, fix it and tell me what you changed.

How to Fix It

1. Check Gateway Auth Token

openclaw config get gateway.auth

2. Set a Token

If no token is set:

openclaw config set gateway.auth.token "your-secure-token"

3. Use Token in WebChat URL

If using WebChat:

http://127.0.0.1:18789?token=YOUR_TOKEN_HERE

4. Restart Gateway

openclaw gateway restart

How to Prevent This

  • Set a token once and reuse it consistently
  • Run openclaw security audit after changing tokens
  • Use the CLI (openclaw chat) which handles auth automatically

Related Errors

Related Guides

Still having trouble?

Ask on Discord