Error Message:
Disconnected from gateway. disconnected (1008): unauthorized:
gateway password missing (enter the password in Control UI settings)
Root Cause: Your OpenClaw gateway authentication is misconfigured or missing.
Quick Fix (5 minutes):
- Generate a gateway token:
openclaw doctor --generate-gateway-token - Clean broken config:
openclaw doctor --fix - Set token auth:
openclaw config set gateway.auth.mode token - Restart gateway:
openclaw gateway restart - Access with token in URL:
http://127.0.0.1:19999/?token=YOUR_TOKEN
What Is the OpenClaw 1008 Unauthorized Error?
If you’re seeing this error when trying to access your OpenClaw opensource automation dashboard:
Disconnected from gateway. disconnected (1008): unauthorized:
gateway password missing (enter the password in Control UI settings)
You’re not alone. This is one of the most common OpenClaw gateway authentication issues, and it’s especially frustrating because the error message doesn’t clearly explain what’s wrong.
What This Error Actually Means
The error indicates that:
- Your OpenClaw gateway is running
- Your browser successfully connected to it
- But the gateway rejected your connection because authentication failed
The gateway uses WebSocket protocol (status code 1008 = policy violation), which means it closed the connection because you didn’t provide valid credentials.
Why This Happens
Common causes:
- No authentication configured: Fresh installation without gateway token setup
- Broken config file: Invalid or conflicting auth settings (like
gateway.auth.typewhen it should begateway.auth.mode) - Missing token in URL: Token-based auth enabled but not provided in browser URL
- Corrupted credentials directory: The
~/.openclaw/credentialsfolder is damaged or has wrong permissions - Port mismatch: Connecting to wrong port or through broken SSH tunnel
Let’s fix each of these systematically.
Prerequisites: Verify Your Setup
Before we dive into fixes, confirm your basic setup:
Check Gateway Status
SSH into your OpenClaw server and run:
openclaw gateway status
What to look for:
Good output:
Gateway Status: Running
Auth Mode: token
Listening: 127.0.0.1:18789
Bad output:
Gateway Status: Stopped
or
Auth Mode: none
or
Auth Mode: (empty)
Check Your SSH Tunnel (if accessing remotely)
You can refer how to install OpenClaw on VPS here.If you’re accessing OpenClaw from Windows/Mac to a remote VPS hosting, verify your SSH tunnel is active:
On Windows:
ssh -N -L 19999:127.0.0.1:18789 root@YOUR_SERVER_IP
On Mac/Linux:
ssh -N -L 19999:127.0.0.1:18789 root@YOUR_SERVER_IP
Keep this terminal window open. If it closes, your tunnel breaks and you’ll get connection errors.
Check What’s Listening on Port 18789
On your OpenClaw server:
sudo netstat -tlnp | grep 18789
or
sudo ss -tlnp | grep 18789
You should see:
tcp 0 0 127.0.0.1:18789 0.0.0.0:* LISTEN 12345/openclaw-gateway
If you see nothing, your gateway isn’t running. If you see 0.0.0.0:18789 instead of 127.0.0.1:18789, your gateway is exposed to the internet (security risk).
Complete Fix: Step-by-Step Solution
Step 1: Generate a Gateway Token
SSH into your OpenClaw server and run:
openclaw doctor generate-gateway-token
You’ll see this prompt:
Create OAuth dir at ~/.openclaw/credentials?
OpenClaw is asking permission to create a folder to store authentication credentials and tokens. Type yes and press Enter.
What happens next:
- OpenClaw creates
~/.openclaw/credentialsdirectory - Generates a secure gateway token
- Prints the token in your terminal
Expected output:
✓ Created credentials directory
✓ Generated gateway token
Gateway token: ocw_............
Copy this token immediately. You’ll need it in Step 5.
If you see errors:
- Permission denied: Run
sudo openclaw doctor --generate-gateway-token - Command not found: Check OpenClaw installation with
which openclaw
Step 2: Clean Broken Configuration
Your config file may have invalid or conflicting keys. OpenClaw’s doctor command can auto-fix this:
openclaw doctor --fix
What this does:
- Removes invalid keys like
gateway.auth.type(should begateway.auth.mode) - Fixes malformed
gateway.bindentries - Validates all config entries against current schema
- Backs up your original config to
~/.openclaw/config.yml.backup
Expected output:
✓ Removed invalid key: gateway.auth.type
✓ Fixed gateway.bind format
✓ Config validated successfully
✓ Backup saved to: ~/.openclaw/config.yml.backup
A common cause of the 1008 error is having both old and new auth config keys present, causing the gateway to get confused about which authentication method to use.
Step 3: Configure Token-Based Authentication
Now set up proper token-based authentication:
openclaw config set gateway.auth.mode token
openclaw config set gateway.auth.token "$(openssl rand -hex 32)"
First command: Sets authentication mode to token-based (not password, not none)
Second command: Generates a cryptographically secure random token and sets it as your gateway password
Verify the configuration:
openclaw config get gateway.auth.mode
openclaw config get gateway.auth.token
Expected output:
token
a9f3c8d1e4...
The token is stored in ~/.openclaw/config.yml. Protect this file with proper permissions:
chmod 600 ~/.openclaw/config.yml
Step 4: Restart the Gateway
Apply your configuration changes:
openclaw gateway restart
Expected output:
Stopping gateway...
✓ Gateway stopped
Starting gateway...
✓ Gateway started on 127.0.0.1:18789
Verify it’s running with correct auth:
openclaw gateway status
You should see:
Gateway Status: Running
Auth Mode: token
Listening: 127.0.0.1:18789
Uptime: 3 seconds
If you see “Stopped”:
openclaw gateway logs
Check the logs for errors. Common issues:
- Port 18789 already in use:
sudo lsof -i :18789 - Permission issues: Try
sudo openclaw gateway start - Config validation errors: Re-run
openclaw doctor --fix
Step 5: Set Up SSH Tunnel (For Remote Access)
If your OpenClaw gateway is on a remote server (not localhost), you need an SSH tunnel to securely access it.
On Separate Windows (PowerShell or Command Prompt):
ssh -N -L 19999:127.0.0.1:18789 root@YOUR_SERVER_IP
On Mac/Linux (Terminal):
ssh -N -L 19999:127.0.0.1:18789 root@YOUR_SERVER_IP
-N: Don’t execute remote commands (tunnel only)-L 19999:127.0.0.1:18789: Forward local port 19999 to remote 127.0.0.1:18789root@YOUR_SERVER_IP: Connect as root to your server
Replace:
YOUR_SERVER_IPwith your actual server IProotwith your username if different
Leave this terminal window open. If you close it, your tunnel dies and you’ll get connection errors.
Test your tunnel:
In a new terminal on your local machine:
curl http://127.0.0.1:19999
If working, you’ll see an HTML response or OpenClaw gateway message.
Step 6: Access Dashboard with Token
Now open your browser and go to:
http://127.0.0.1:19999/?token=YOUR_TOKEN_HERE
Replace YOUR_TOKEN_HERE with:
- The token from Step 1 (
ocw_...), or - The token from Step 3 (the long hex string from
openclaw config get gateway.auth.token)
Example:
http://127.0.0.1:19999/?token=ocw_a1b2c3d4e5f6g..
- Browser connects to your OpenClaw dashboard
- No more 1008 unauthorized errors
- Dashboard loads successfully

If you still see the error:
- Double-check the token in the URL matches what’s in your config
- Verify the SSH tunnel is still active
- Check gateway logs:
openclaw gateway logs - Try clearing browser cache and cookies for
127.0.0.1
Alternative Fix: Password-Based Authentication
If you prefer password-based auth over tokens (not recommended for production):
openclaw config set gateway.auth.mode password
openclaw config set gateway.auth.password "YourSecurePasswordHere"
openclaw gateway restart
Then access without token in URL:
http://127.0.0.1:19999
You’ll be prompted for the password in the UI.
Why token auth is better:
- Tokens can be easily rotated
- No password prompt in UI (cleaner UX)
- Easier to script and automate
- More secure for API access
Exact OpenClaw Error Messages and the Fix for Each
The Control UI shows slightly different text depending on your OpenClaw version. Find the line you see below. The fixes follow the OpenClaw dashboard documentation and its troubleshooting pages. Run every command on the server where the Gateway runs.
“disconnected (1008): unauthorized: gateway token missing”
Newer versions add “open the dashboard url and paste the token in control ui settings” or “open a tokenized dashboard url or paste token in control ui settings”. OpenClaw logs this as AUTH_TOKEN_MISSING: the Gateway expects a shared token and the browser did not send one. Show the token:
openclaw gateway auth-token --show
Paste it into the Gateway secret field on the login screen or under Settings, Gateway. Treat it like a password. If no token is set yet, generate one, restart the Gateway, then show it again:
openclaw doctor --generate-gateway-token
You can also run openclaw dashboard on the server. It opens (or copies) a single-use pairing link for one browser, and openclaw dashboard --json prints it as browserUrl, valid for ten minutes.
“unauthorized: gateway token mismatch”
Logged as AUTH_TOKEN_MISMATCH: the browser sent a token, but it is not the one the Gateway uses now. This usually happens after the token was regenerated or the config was edited. Show the current token with openclaw gateway auth-token --show and paste it again. If it keeps failing, list the paired devices and reissue the token for yours:
openclaw devices list
openclaw devices rotate --device <deviceId> --role operator
“unauthorized: device token mismatch (rotate/reissue device token)”
Logged as AUTH_DEVICE_TOKEN_MISMATCH: the token your browser stored for this device is stale or was revoked. Rotate it with the openclaw devices rotate command above. If that does not help, remove the device and approve it again, then reconnect with the current Gateway token:
openclaw devices remove <deviceId>
openclaw devices approve <requestId>
“unauthorized: gateway password missing (enter the password in control ui settings)”
Your Gateway uses password mode (gateway.auth.mode set to password) and the browser sent no password. Enter the value of gateway.auth.password, or of the OPENCLAW_GATEWAY_PASSWORD environment variable, in the Gateway secret field. The dashboard does not keep the password after a page reload, so you enter it again each time. If you changed the environment variable, restart the Gateway first.
“disconnected (1008): control ui requires https or localhost (secure context)”
You opened the dashboard by the server’s IP address over plain HTTP. Current OpenClaw documentation says pairing works over plain HTTP and only features such as the live camera preview need HTTPS, so updating OpenClaw may remove this message. Either way, the safe fix is the same: do not open port 18789 to the internet. Reach it through an SSH tunnel from your own computer:
ssh -N -L 18789:127.0.0.1:18789 user@your-server
Then open http://127.0.0.1:18789/ in your browser. The browser counts 127.0.0.1 as a secure context. Another option is Tailscale Serve: run openclaw gateway --tailscale serve and open the HTTPS address Tailscale gives you.
“control ui requires device identity” or “device identity required”
The browser did not present the device identity the Control UI needs. OpenClaw’s docs are clear that the shared token or password does not replace it: the Control UI always needs a signed browser identity. Open the dashboard in a normal browser window (not a locked-down or private mode that blocks storage), over the SSH tunnel above, and complete pairing.
“origin not allowed (open the control ui from the gateway host or allow it in gateway.controlui.allowedorigins)”
You opened the dashboard from an address the Gateway does not trust, such as a public domain behind a reverse proxy. Loads from the Gateway host itself, a private LAN address, Tailscale or an SSH tunnel need no setting. For a public address, list that exact origin in gateway.controlUi.allowedOrigins (note the capital letters), or set gateway.publicOrigin. Avoid ["*"], which allows every website.
“not connected to gateway, message not sent”
The chat window lost its connection to the Gateway, so your message never left the browser. Check that the Gateway is running (see Check Gateway Status above), that your SSH tunnel is still open, and that the page is not showing one of the 1008 errors in this list. Reload the page after fixing the cause and send the message again.
“disconnected (1008): pairing required”
This one means your token or password was accepted, but this browser is a new device that the Gateway has not approved yet. Keep the dashboard tab open, then approve the request on the server:
openclaw devices list
openclaw devices approve <requestId>
Use the request ID from the list. Running openclaw devices approve without an ID, or with --latest, only previews the newest request and does not approve it. Our complete pairing required guide covers this error in more depth.
Troubleshooting: Still Not Working?
Error: “Connection refused”
Symptom: Browser can’t connect at all (not even seeing the 1008 error)
Possible causes:
- Gateway isn’t running:
openclaw gateway start - SSH tunnel died: Check if the SSH window is still open
- Wrong port: Verify you’re using
19999locally,18789on server - Firewall blocking connection
# On server
openclaw gateway status
sudo netstat -tlnp | grep 18789
# On local machine
# Kill any existing tunnel
pkill -f "ssh.*19999"
# Start fresh tunnel
ssh -N -L 19999:127.0.0.1:18789 root@YOUR_SERVER_IP
Error: “Invalid token”
Symptom: Still getting 1008 unauthorized even with token in URL
Possible causes:
- Token in URL doesn’t match config
- Token got corrupted when copying
- Using old token after regenerating
# Get the current valid token
openclaw config get gateway.auth.token
# Or regenerate and use new one
openclaw doctor --generate-gateway-token
Copy the exact token output and use it in your URL. Watch out for:
- Extra spaces
- Line breaks if token wrapped in terminal
- Using
ocw_...token when config has the hex token (or vice versa)
Error: Gateway keeps restarting
Symptom: openclaw gateway status shows it’s running, but it crashes shortly after
Check logs:
openclaw gateway logs --tail 50
Common causes:
- Port conflict: Another process is using 18789
- Config validation errors: Invalid YAML syntax
- Permission issues: Gateway can’t write to log directory
Fix port conflict:
sudo lsof -i :18789
# Kill the conflicting process
sudo kill <PID>
openclaw gateway restart
Fix config errors:
openclaw doctor --fix
openclaw config validate
Error: “Pairing required”
Symptom: Dashboard loads but shows “Device pairing required” message
Cause: Your token or password was accepted, but this browser has not been approved as a device yet. Switching the authentication mode does not fix it.
openclaw devices list
openclaw devices approve <requestId>
See “disconnected (1008): pairing required” in the error list above for the details.
Conclusion
By following this setup, you’ve successfully completed the OpenClaw installation and secure gateway configuration on a VPS. Seeing health: ok and an active gateway status confirms that your OpenClaw service is running correctly. More importantly, enabling token-based authentication and accessing the dashboard through an SSH tunnel ensures your setup is not only functional, but also secure.
This approach protects your gateway from unauthorized access, avoids common configuration pitfalls, and gives you a reliable way to manage OpenClaw remotely without exposing sensitive ports to the public internet. Once the token is configured and the tunnel is active, you have a production-ready foundation to start building workflows, automations, or AI agents on top of OpenClaw.
FAQ
1. Do I need to regenerate the token every time I restart the gateway?
No. The token is stored in your config file and persists across restarts. You only need to regenerate if you want to rotate it for security or if you lost it.
2. Can I use the same token for multiple users/browsers?
Yes. Token-based auth uses a single shared token. Anyone with the token can access the gateway. For multi-user scenarios with individual credentials, consider password auth or implement OAuth pairing.
3. Can I have multiple tokens?
No. OpenClaw gateway only supports one active token at a time. If you set a new token, the old one stops working immediately.
4. Does the token expire?
No. OpenClaw tokens don’t have expiration times. They’re valid until you change them.