Claude Managed Agents Domain Restrictions: A Fix Guide
Restrict web search and web fetch domains in Claude Managed Agents. Learn to configure allowed_hosts, allowed_domains, and fix 400 errors.

Claude Managed Agents in limited networking environments enforce domain limits through environment-level allowed_hosts and tool-level allowed_domains or blocked_domains arrays. If a host is not in allowed_hosts, the agent receives a url_not_allowed error for web_fetch and web_search silently omits those results. Setting this up requires aligning your environment networking policies with your tool configurations.
The Claude Platform release notes detail two layers of control. You configure network egress for the sandbox using allowed_hosts, and you restrict specific tools using allowed_domains or blocked_domains on the tool's entry in the agent_toolset_20260401 configs array. If the tool-level list includes a host missing from the environment-level list, session creation fails with a 400 error. Getting this right prevents data exfiltration and keeps your agents from reaching unintended domains.
How environment allowed_hosts limits web tools#
As of October 7, 2026, a cloud environment with limited networking applies its allowed_hosts list to the web_search and web_fetch tools. This means your environment network policy is the single source of truth for outbound web traffic from the agent. If a host is not listed in allowed_hosts, the tools cannot reach it.
When allowed_hosts does not match a requested host, web_fetch returns a url_not_allowed error result to the agent. The web_search tool omits results from such hosts entirely. If allowed_hosts lists no hosts, neither tool returns a page or a search result. To let the tools reach a host, you must add it to allowed_hosts, which also opens it to the sandbox.
The allow_package_managers and allow_mcp_servers settings do not add hosts for these web tools. If you want your agent to fetch a package registry URL or an MCP server endpoint over HTTP using web_fetch, you must explicitly add those hosts to allowed_hosts. Unrestricted networking and self-hosted environments do not limit these tools, so these restrictions only apply when you explicitly configure limited networking.
Configure allowed_domains and blocked_domains on tools#
For finer control over what the web_search and web_fetch tools can access, you can set allowed_domains or blocked_domains directly on the tool's configuration. The Claude Platform release notes from August 19, 2026 state that you set these on the tool's entry in the agent_toolset_20260401 configs array.
Each config entry is identified by its name and typed by an optional type. Requests that pass only name, enabled, and permission_policy continue to work, but adding allowed_domains or blocked_domains lets you scope the tool's behavior. The web_fetch tool also accepts max_content_tokens and web_search accepts user_location in this same config object.
Here is an example of how you might structure this configuration within an agent definition. This JSON excerpt shows the configs array for a web_fetch tool, limiting it to a specific domain.
{
"tools": [
{
"name": "web_fetch",
"type": "web_fetch",
"enabled": true,
"configs": [
{
"name": "web_fetch",
"allowed_domains": ["docs.example.com"],
"max_content_tokens": 1000
}
]
}
]
}
If you want to block a specific domain but allow everything else permitted by allowed_hosts, use blocked_domains instead. This is useful when you want the agent to have general web access but prevent it from reaching a known internal or problematic host.
The web_fetch prior context rule#
Domain restrictions are not the only limit on web_fetch. As of October 7, 2026, the web_fetch tool fetches only URLs that have already appeared in the session. This includes URLs in the text of a user message, a web_search result, or a page that web_fetch returned earlier. This reduces the risk of data exfiltration.
A URL that appears only in Claude's own output, the agent's system prompt, an attached document, or the output of a tool such as bash, read, or an MCP tool does not count. A web_fetch call for such a URL returns a url_not_in_prior_context error result to the agent.
To let the agent fetch a URL that has not appeared in prior context, send that URL in the text of a user.message event. This ensures the URL is part of the conversation history before the agent attempts to fetch it.
Common gotchas with limited networking#
The most common issue is a 400 error when creating or updating a session. With limited networking, creating a session fails with a 400 error when an enabled web tool's allowed_domains has an entry not within allowed_hosts. A session update that adds such an entry also fails with the same error.
To fix this, you must either add the host to allowed_hosts or remove the entry from allowed_domains. The tool-level allowed_domains list must be a subset of the environment-level allowed_hosts list.
Another gotcha is subdomain matching. An allowed_hosts entry matches one exact host unless it starts with *., so docs.example.com is not within ["example.com"]. You must use *.example.com to match all subdomains, or list each subdomain explicitly.
You can run this Python script to test your host matching logic before deploying an agent. It demonstrates the exact matching rule and the wildcard rule.
def is_host_allowed(host, allowed_hosts):
for pattern in allowed_hosts:
if pattern.startswith("*."):
suffix = pattern[1:]
if host.endswith(suffix) and len(host) > len(suffix):
return True
elif host == pattern:
return True
return False
allowed = ["example.com", "*.github.io"]
print(is_host_allowed("docs.example.com", allowed))
print(is_host_allowed("example.com", allowed))
print(is_host_allowed("blog.github.io", allowed))
If you are running agents in self-hosted sandboxes, note that the allowed_hosts restrictions for web_search and web_fetch do not apply. The release notes state that unrestricted networking and self-hosted environments do not limit these tools. If you need similar restrictions in a self-hosted environment, you must enforce them at the network level, such as with egress proxies or firewall rules.
For managing costs while running these agents, the Claude pricing page notes that web search triggered inside a session incurs the standard $10 per 1,000 searches. To keep token costs down, see How to Use Claude Prompt Caching and Read Cache Usage. If you are routing tool traffic through MCP, review How to Build an MCP Server in Python and Test It Locally to ensure your server endpoints are accessible.
Quick reference for web tool policies#
Use this checklist when configuring domain restrictions for your Claude Managed Agents:
- Check if your environment uses limited networking. If it does,
allowed_hostslimitsweb_searchandweb_fetch. - Add all necessary hosts to
allowed_hosts. Remember thatallow_package_managersandallow_mcp_serversdo not add hosts for these web tools. - Use
*.domain.comfor wildcard subdomain matching inallowed_hosts. Exact matches are required otherwise. - Set
allowed_domainsorblocked_domainson theagent_toolset_20260401configsarray for tool-specific limits. - Ensure every entry in a tool's
allowed_domainsis also inallowed_hoststo avoid 400 errors on session creation. - For
web_fetch, remember the prior context rule. Provide URLs inuser.messageevents if the agent needs to fetch them.
For the full list of changes and behaviors, see the Claude Platform release notes and the Claude pricing page.
Quick answers
Why does my Claude Managed Agents session fail with a 400 error?
With limited networking, creating a session fails with a 400 error if an enabled web tool's allowed_domains includes a host not present in the environment's allowed_hosts. Add the host to allowed_hosts or remove it from allowed_domains.
Why does web_fetch return a url_not_allowed error?
The web_fetch tool returns a url_not_allowed error when it tries to fetch a URL on a host that the environment's allowed_hosts list does not match. Add the target host to allowed_hosts to fix it.
Why does web_fetch return a url_not_in_prior_context error?
The web_fetch tool only fetches URLs that have already appeared in the session, such as in a user message or a web_search result. If a URL appears only in the agent's output or a bash tool result, it returns this error. Send the URL in a user.message event.
Does allow_package_managers or allow_mcp_servers open hosts for web tools?
No. The allow_package_managers and allow_mcp_servers settings add no hosts for the web_search and web_fetch tools. You must explicitly add hosts to allowed_hosts.
How do I allow all subdomains in allowed_hosts?
An allowed_hosts entry matches one exact host unless it starts with *. To allow all subdomains of example.com, use *.example.com. Otherwise, docs.example.com is not covered by example.com.
Did this solve it?
One tap. No account.
Sorry about that. What was missing?
from 0 readers
Saved you an hour? Send a tip.
USDC or ETH on Base, Ethereum, Arbitrum and more. Keeps the notes free and the examples running.
Network
0xc783bc5c3fa14cEC3f09A22284bC91C5AF0d59e1
On a computer? Scan the code with your phone wallet, or copy the address.
Pick the network your wallet or exchange uses. USDC works on all six; ETH on Base, Ethereum, Arbitrum and Optimism. Don't send on Tron or Solana: this address doesn't exist there. Tips are optional and unlock nothing; every guide stays free.
Discussion
Start the discussion
Next note