Skip to content
Browse the documentation

Troubleshooting

Fixes for common AgentLock problems: 401 on signed requests, replay errors, rate limits, missing approvals and MCP connection failures.

Agent gets 401 "Unauthorized" on signed requests

The gateway deliberately returns the same generic 401 for every pre-authentication failure (unknown agent ID, wrong signature, missing nonce) so the responses can't be used to probe agent state. Work through these causes in order:

  1. Agent ID typo or deleted agent — Verify the UUID in the dashboard.
  2. Wrong private key — The key doesn't match the registered public key. Re-register or generate a new keypair with generateKeypair().
  3. Clock skew >5 minutes — Sync via NTP. Check: compare Date.now() with an online time service.
  4. Body modified after signing — A proxy or middleware changed the JSON. Ensure nothing touches the body after the SDK signs it.
  5. Wrong method, path or signed body — Signature version 2 (x-signature-version: 2) signs the HTTP method and the URL path without query string, so a signature made for one endpoint fails on another. GET endpoints sign a fixed body: {"requestId":"<id>"} for result polling, {"_poll":"messages"} for reading messages and {} for listing credentials or SSH sessions.
  6. Wrong encoding — Private key must be valid base64. Check: Buffer.from(key, 'base64').length should be 64.
  7. Missing or wrong nonce header — Must be x-nonce (not x-csp-nonce).

The specific failure reason is not returned. Compare your signing code with the signing example in the API reference, or sign and verify locally with the agentlock-shared package that the Node.js SDK uses.

Debug locally:

typescript
import { signRequest, verifyRequest, generateKeypair } from 'agentlock-shared';
const { publicKey, privateKey } = generateKeypair();
const target = { method: 'POST', path: '/api/gateway/request' };
const headers = signRequest({ test: true }, 'agent-id', privateKey, target);
verifyRequest({ test: true }, headers, publicKey, undefined, target); // should not throw

Agent gets "Replay detected"

The nonce was already used within the 10-minute TTL window.

How it works: The gateway remembers every nonce of an agent for 10 minutes and rejects a request that repeats one.

Causes:

  • Request retried without generating a new nonce
  • HTTP client auto-retrying POST with same headers
  • A retry after HTTP 429 or 5xx by an older SDK version that reused the nonce: call the method again, or update to agentlock-sdk-node 0.6.0, agentlock-sdk 0.5.0 or agentlock-mcp-server 0.5.0, which sign every retry anew
  • Copy-pasting curl commands and re-running them

Fix: Generate a fresh nonce per request. The SDKs generate 16 random bytes per request automatically. If signing manually: crypto.randomBytes(16).toString('base64').

Agent gets "Rate limit exceeded"

Rate limit layers:

  • IP-based: 60 action requests/min per source IP
  • Agent-based: 60 req/min per agent, counted separately per endpoint (120 for permission routing)
  • Workspace-based: 120 (Free), 600 (Pro) or 2,400 (Team) action requests/min
  • Policy hourly: configurable maxActionsPerHour (default 100), answered with "Hourly action limit exceeded"

Solutions:

  • Respect the Retry-After header. The SDKs retry automatically; with an older SDK version, a 409 "Replay detected" right after a 429 means the retry reused the nonce, so wait and call the method again.
  • Increase awaitResult poll interval from default 2s to 5-10s.
  • Use webhook_url instead of polling.
  • Batch operations where possible.
  • For messages, increase onMessage poll interval.

Approvals not showing up

Check in order:

  1. Agent status — Must be active. Revoked/suspended agents can't create requests.
  2. Policy decision — The request may be auto-allowed (ALLOW) or blocked (BLOCK). Check the decision field in the gateway response.
  3. Approval expired — Default TTL is 5 minutes. Check Timeline for expired entries.
  4. User role — Only Owner, Admin, and Approver roles can see approvals. Member role cannot.
  5. allowed_approvers — If the policy rule has specific approvers, only they see it.
  6. Safe Mode — When active, every action from every agent is BLOCKED, including reads. No requests reach the approvals queue. Disable Safe Mode in Settings to resume activity.
  7. Push notifications — On mobile, verify the device token is registered in Settings.
  8. Live updates — The dashboard updates live over a realtime connection. Try refreshing the page.

Browser sessions not working

  1. Plan — Free plan has 0 sessions. Need Pro (2 concurrent) or Team (5).
  2. Concurrent limit — Close existing sessions (browser.close) before opening new ones.
  3. Domain restrictions — Navigation outside allowed_domains is blocked. The initial URL's domain is always included.
  4. Selector issues — selector takes a Playwright selector such as #submit, text=Sign in or role=button[name="Save"], at most 500 characters. ref is accepted as another name for the same field. Build selectors from the roles and names in the accessibility snapshot.
  5. Session expired — Sessions expire 30 minutes after they open (HTTP 410). Open a new session.
  6. TOTP errors — Verify the credential has a valid base32 TOTP secret.
  7. Approval timeout — browser.open always requires approval. If it expires, re-submit.
  8. Actions refused with HTTP 403 — Inside a session an action runs only when the policy allows it; one the policy would send for approval is refused. The default policy allows only snapshot, screenshot, scroll and close, so add Allow rules for click, type, navigate and the other tools the agent needs.

Agent not receiving messages

  1. Not polling — Messages are delivered via polling, not push. Call get_messages or use onMessage().
  2. Already read — Messages are marked as read when they are fetched, also when the response is lost on the way (for example a 502 or 504). Call again with include_read: true and since set to the time of your last received response.
  3. Wrong since param — If the timestamp is in the future, no messages are returned.
  4. Message expired — Check plan retention: Free 7d, Pro 30d, Team 90d.
  5. Thread ownership — Agents can only read their own threads.
  6. Plan limit — If workspace exceeded monthly message limit, users can't send new messages.
  7. Auth error — Check for 401 errors in agent logs. Same auth as other gateway endpoints.

MCP server connection fails

  1. Missing auth — Set AGENTLOCK_TOKEN, or AGENT_ID and AGENT_PRIVATE_KEY for signing, in the server's environment. Flags such as --token, --key and --agent-id are rejected.
  2. Wrong URL — Default: https://app.agentlock.net. Set AGENTLOCK_URL or --url only to reach a different AgentLock address.
  3. MCP client config — Verify the command, args and env in your MCP settings:
json
{ "command": "npx", "args": ["-y", "agentlock-mcp-server"], "env": { "AGENTLOCK_TOKEN": "YOUR_TOKEN" } }
  1. Node version — Requires Node.js 18+ (native fetch).
  2. Timeout — 30s per request, 5min for result polling. Long approvals wait within this window.
  3. Check stderr — The MCP server outputs errors to stderr. Check your MCP client's output panel.

Webhook not receiving callbacks

  1. HTTPS required — HTTP URLs are silently rejected.
  2. SSRF protection — Private IPs (127.x, 10.x, 192.168.x) are blocked even if hostname looks public. Check dig your-domain.
  3. Timeout — 5-second delivery timeout.
  4. No retries — Delivery is fire-and-forget. Use polling as primary, webhooks as supplementary.
  5. Only final outcomes — Webhooks are sent for SUCCEEDED, FAILED, DENIED and EXPIRED; an EXPIRED webhook can come up to 5 minutes after the approval ran out. Blocked requests send none.
  6. Signature does not match — Check the raw body before parsing it, with the secret from Settings > Webhook Signing Secret, whsec_ included. After a rotation only the new secret matches.

Dashboard shows stale data

  1. Retention period — Data older than plan retention is cleaned up (Free: 14d timeline/7d messages, Pro: 90d/30d, Team: 365d/90d).
  2. Disabled features — Check Settings > Data. The Timeline can be disabled.
  3. Browser cache — Hard-refresh (Ctrl+Shift+R) or clear cache.
  4. Realtime disconnection — Refresh the page to re-establish the WebSocket.
  5. Empty entries — If entries show empty content, refresh the page.
  6. Workspace access — You only see data for your workspace. Verify membership in Settings > Members.
Troubleshooting | AgentLock Docs