{"record":{"id":"a783dfa09a19f48a","repo":"google-gemini/gemini-cli","slug":"domain-not-allowed-the-requested-domain-is-not-in","errorCode":null,"errorMessage":"Domain not allowed: The requested domain is not in the allowed list.","messagePattern":"Domain not allowed: The requested domain is not in the allowed list\\.","errorType":"exception","errorClass":"DomainNotAllowedError","httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/browser/browserManager.ts","lineNumber":345,"sourceCode":"    if (signal?.aborted) {\n      throw signal.reason ?? new Error('Operation cancelled');\n    }\n\n    // Hard enforcement of per-action rate limit\n    if (!isInternal) {\n      if (this.actionCounter >= this.maxActionsPerTask) {\n        const error = new Error(\n          `Browser agent reached maximum action limit (${this.maxActionsPerTask}). ` +\n            `Task terminated to prevent runaway execution. To config the limit, use maxActionsPerTask in the settings.`,\n        );\n        throw error;\n      }\n      this.actionCounter++;\n    }\n\n    const errorMessage = this.checkNavigationRestrictions(toolName, args);\n    if (errorMessage) {\n      throw new DomainNotAllowedError(errorMessage);\n    }\n\n    const client = await this.getRawMcpClient();\n    const callPromise = client.callTool(\n      { name: toolName, arguments: args },\n      undefined,\n      { timeout: MCP_TIMEOUT_MS },\n    );\n\n    let result: McpToolCallResult;\n\n    // If no signal, just await directly\n    if (!signal) {\n      result = this.toResult(await callPromise);\n    } else {\n      // Race the call against the abort signal\n      let onAbort: (() => void) | undefined;\n      try {","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/core/src/agents/browser/browserManager.ts#L327-L363","documentation":"Thrown as DomainNotAllowedError from callTool() when checkNavigationRestrictions returns a non-empty message. It fires for navigate_page / new_page when the target URL's hostname (or an http/https URL embedded in query params or fragment) is not matched by any entry in customConfig.allowedDomains. The error class is caught by mcpToolWrapper to terminate the agent run.","triggerScenarios":"callTool('navigate_page', { url: 'https://blocked.example' }) (or 'new_page') when allowedDomains is configured and the hostname is not in it; also when a query/fragment parameter contains a URL to a disallowed host (proxy/translate bypass attempt).","commonSituations":"allowedDomains allowlist is narrow and the agent legitimately needs a sibling subdomain not covered; wildcard pattern misconfigured (e.g. *.example.com does not match example.com itself per isDomainAllowed); agent follows a redirect or embedded link outside the allowlist; user expects wildcards to cover the apex domain.","solutions":["Add the required hostname (or a *.domain wildcard) to customConfig.allowedDomains.","If using a wildcard *.example.com and the apex is needed, also add 'example.com' explicitly (isDomainAllowed only matches base or *.base subdomains for wildcards).","Drop the allowedDomains config entirely if domain restriction is not required.","Avoid embedding off-domain URLs in query parameters of allowed-domain URLs."],"exampleFix":"// before\nallowedDomains: ['*.example.com']\n// navigating to https://example.com (apex) -> blocked\n\n// after: include the apex explicitly\nallowedDomains: ['example.com', '*.example.com']","handlingStrategy":"type-guard","validationCode":"function isAllowed(hostname, allowed) {\n  const h = hostname.replace(/\\.$/, '');\n  return allowed.some(p =>\n    p.startsWith('*.') ? h === p.slice(2) || h.endsWith('.' + p.slice(2)) : h === p\n  );\n}\n// Pre-check navigation targets:\nfunction checkUrl(url, allowed) {\n  const host = new URL(url).hostname;\n  if (!isAllowed(host, allowed)) throw new Error('Domain not allowed: ' + host);\n}","typeGuard":"import { DomainNotAllowedError } from './browserManager.js';\nfunction isDomainNotAllowed(e) {\n  return e instanceof DomainNotAllowedError ||\n    (e instanceof Error && e.name === 'DomainNotAllowedError');\n}","tryCatchPattern":"try {\n  await bm.callTool('navigate_page', { url });\n} catch (e) {\n  if (e instanceof DomainNotAllowedError) {\n    // add host to allowedDomains or pick an allowed URL\n  }\n  throw e;\n}","preventionTips":["Include both apex and wildcard in allowedDomains when needed.","Validate target URLs against the allowlist before invoking navigate_page/new_page.","Avoid embedding off-domain URLs in query parameters."],"tags":["browser","security","config","domain-allowlist"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}