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:
- Agent ID typo or deleted agent — Verify the UUID in the dashboard.
- Wrong private key — The key doesn't match the registered public key. Re-register or generate a new keypair with
generateKeypair(). - Clock skew >5 minutes — Sync via NTP. Check: compare
Date.now()with an online time service. - Body modified after signing — A proxy or middleware changed the JSON. Ensure nothing touches the body after the SDK signs it.
- 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. - Wrong encoding — Private key must be valid base64. Check:
Buffer.from(key, 'base64').lengthshould be 64. - Missing or wrong nonce header — Must be
x-nonce(notx-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:
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 throwAgent 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-Afterheader. 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
awaitResultpoll interval from default 2s to 5-10s. - Use
webhook_urlinstead of polling. - Batch operations where possible.
- For messages, increase
onMessagepoll interval.
Approvals not showing up
Check in order:
- Agent status — Must be
active. Revoked/suspended agents can't create requests. - Policy decision — The request may be auto-allowed (ALLOW) or blocked (BLOCK). Check the
decisionfield in the gateway response. - Approval expired — Default TTL is 5 minutes. Check Timeline for expired entries.
- User role — Only Owner, Admin, and Approver roles can see approvals. Member role cannot.
- allowed_approvers — If the policy rule has specific approvers, only they see it.
- 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.
- Push notifications — On mobile, verify the device token is registered in Settings.
- Live updates — The dashboard updates live over a realtime connection. Try refreshing the page.
Browser sessions not working
- Plan — Free plan has 0 sessions. Need Pro (2 concurrent) or Team (5).
- Concurrent limit — Close existing sessions (
browser.close) before opening new ones. - Domain restrictions — Navigation outside
allowed_domainsis blocked. The initial URL's domain is always included. - Selector issues —
selectortakes a Playwright selector such as#submit,text=Sign inorrole=button[name="Save"], at most 500 characters.refis accepted as another name for the same field. Build selectors from the roles and names in the accessibility snapshot. - Session expired — Sessions expire 30 minutes after they open (HTTP 410). Open a new session.
- TOTP errors — Verify the credential has a valid base32 TOTP secret.
- Approval timeout —
browser.openalways requires approval. If it expires, re-submit. - 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
- Not polling — Messages are delivered via polling, not push. Call
get_messagesor useonMessage(). - 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: trueandsinceset to the time of your last received response. - Wrong
sinceparam — If the timestamp is in the future, no messages are returned. - Message expired — Check plan retention: Free 7d, Pro 30d, Team 90d.
- Thread ownership — Agents can only read their own threads.
- Plan limit — If workspace exceeded monthly message limit, users can't send new messages.
- Auth error — Check for 401 errors in agent logs. Same auth as other gateway endpoints.
MCP server connection fails
- Missing auth — Set
AGENTLOCK_TOKEN, orAGENT_IDandAGENT_PRIVATE_KEYfor signing, in the server's environment. Flags such as--token,--keyand--agent-idare rejected. - Wrong URL — Default:
https://app.agentlock.net. SetAGENTLOCK_URLor--urlonly to reach a different AgentLock address. - MCP client config — Verify the command, args and env in your MCP settings:
{ "command": "npx", "args": ["-y", "agentlock-mcp-server"], "env": { "AGENTLOCK_TOKEN": "YOUR_TOKEN" } }- Node version — Requires Node.js 18+ (native fetch).
- Timeout — 30s per request, 5min for result polling. Long approvals wait within this window.
- Check stderr — The MCP server outputs errors to stderr. Check your MCP client's output panel.
Webhook not receiving callbacks
- HTTPS required — HTTP URLs are silently rejected.
- SSRF protection — Private IPs (127.x, 10.x, 192.168.x) are blocked even if hostname looks public. Check
dig your-domain. - Timeout — 5-second delivery timeout.
- No retries — Delivery is fire-and-forget. Use polling as primary, webhooks as supplementary.
- 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.
- 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
- Retention period — Data older than plan retention is cleaned up (Free: 14d timeline/7d messages, Pro: 90d/30d, Team: 365d/90d).
- Disabled features — Check Settings > Data. The Timeline can be disabled.
- Browser cache — Hard-refresh (Ctrl+Shift+R) or clear cache.
- Realtime disconnection — Refresh the page to re-establish the WebSocket.
- Empty entries — If entries show empty content, refresh the page.
- Workspace access — You only see data for your workspace. Verify membership in Settings > Members.