Last verified

Can Claude Code search the web?

Yes.
Built in · but permission-gated

Yes — there's a built-in WebSearch tool, and it fetches live results with sources. The catch is permission. Run a headless prompt with default settings and it declines, telling you to approve the tool rather than guessing from memory. Pass --allowedTools WebSearch and the same prompt returns an answer with citations in about 20 seconds. In an interactive session you approve it once when asked.

Live results with sources — cited a vendor blog URL in our run 20.6 seconds for a search-and-answer round trip Refuses by default in headless -p mode until approved Says so honestly — asks for approval instead of answering from memory Flag order matters--allowedTools before -p, or it eats your prompt
§ 01 / PROOF

We actually ran it.

Methodology →
TEST RUN · AUG 01, 2026 · 2 RUNS

It refused first — and that refusal is the more interesting result.

Run one, default permissions, headless: we asked for the current version number of a fast-moving open-source framework — a fact that is wrong the moment it's memorised. Claude Code declined to answer and asked us to approve a tool first, adding that it couldn't answer reliably from memory since a version number would be outdated by its knowledge cutoff. That is the behaviour you want from a tool with a search capability it can't currently reach: refuse, don't improvise. It took 39 seconds to get there.

Run two, same prompt with --allowedTools WebSearch: it searched, answered, and printed a Sources block with a live URL to the vendor's own release announcement. Elapsed 20.6 seconds.

One CLI gotcha worth writing down, because the error message doesn't explain it. --allowedTools takes a variadic list, so claude -p --allowedTools WebSearch "my prompt" treats the prompt as another tool name and fails with "Input must be provided either through stdin or as a prompt argument". Put the flag first: claude --allowedTools WebSearch -p "my prompt".

Default headless: refused · asked to approveWith permission: searched · cited sourceRefusal run: 39.4 sSearch run: 20.6 sTool name: WebSearchCLI version: 2.1.170
$ claude -p "...current version of Astro?"
please approve one of those tools (e.g. allow
WebSearch) and I'll return just the number.
→ 39.4 s, no answer
$ claude --allowedTools WebSearch -p "..."
Sources:
- https://astro.build/blog/astro-7/
→ 20.6 s, answered with citation
$
§ 02 / WHY

Why the gate is there.

2.1
Search is an outbound action, so it asks

Claude Code treats reaching the open web the way it treats running a command or editing a file: an action with consequences, approved rather than assumed. Interactively you're prompted once and can allow it for the session. Headless, there's nobody to ask — so it stops and says what it needs.

The failure mode this avoids is the one that makes AI answers untrustworthy: a confident version number, price or date recalled from training data and presented as current. Refusing is the better behaviour, and it's what we observed.

2.2
Granting it in scripts and CI

For automation, name the tool explicitly: claude --allowedTools WebSearch -p "…". Keep the grant narrow — allowing one tool is a different decision from bypassing permission checks wholesale, and the CLI offers both. There is a --dangerously-skip-permissions flag; the name is the documentation.

Watch the argument order, per the gotcha above. The list is variadic and will happily swallow whatever follows it, including your prompt.

2.3
Fetching a page is not the same as searching

Searching and fetching a known URL are separate capabilities, and there's a wrinkle worth knowing if you route the tool through a gateway: per Anthropic's network docs, the fetch tool still calls api.anthropic.com for a domain safety check unless skipWebFetchPreflight is set. Even on Bedrock or your own gateway, that one call goes home.

And none of it works without a connection at all — see can Claude Code work offline, where we measured what happens when the network isn't there.

Frequently asked.

Quick follow-ups people search after this question.

Q · 01 Why did Claude Code refuse to search for me? +
Because the tool wasn't approved. In a headless -p run with default permissions there's nobody to ask, so it stops and names what it needs. Pass --allowedTools WebSearch, or approve it once when prompted in an interactive session.
Q · 02 How do I allow web search in a script? +
claude --allowedTools WebSearch -p "your prompt". Keep the flag before -p: the list is variadic, so trailing it will swallow your prompt and produce the misleading error Input must be provided either through stdin or as a prompt argument.
Q · 03 Does it cite what it found? +
In our run, yes — the answer ended with a Sources: block containing a live URL to the vendor's own announcement. That's the difference between a searched answer and a remembered one, and it's worth checking the links rather than trusting the summary.
Q · 04 Can it browse a specific URL rather than search? +
Fetching a known page is a separate tool from searching. One wrinkle if you route through a gateway or Bedrock: per Anthropic's network docs the fetch tool still calls api.anthropic.com for a domain safety check unless you set skipWebFetchPreflight.