To block every crawler from your whole site, put two lines in the robots.txt file at your domain’s root: User-agent: * and Disallow: /. Every search engine bot that follows the robots.txt standard will then stop fetching your pages, though it won’t make Google forget the URLs it already knows.
User-agent: *
Disallow: /
That rule is right for a few narrow cases and wrong for almost every live business site. Below is what it actually does, the near-miss that does the opposite, the variations people usually want instead, and how to back out of it fast if it ended up on production by mistake.
What the two lines do
User-agent: * starts a group that applies to any crawler without a more specific group of its own. Disallow: / matches every path on the site, because every URL path starts with a slash. Google’s list of useful robots.txt rules gives exactly this pair as the way to disallow crawling of the entire site.
Three details catch people out:
- It’s per host. The file only governs the host it sits on. RFC 9309, the robots.txt standard published in September 2022, says it must live at
/robots.txt, all lowercase, in the top-level path. A block onstaging.example.com/robots.txtdoes nothing towww.example.com, and the reverse. - AdsBot isn’t included. Google notes that the wildcard “doesn’t match the various AdsBot crawlers, which must be named explicitly.” If you run Google Ads and want those bots out too, add a group for them by name.
- A named group replaces the wildcard. Google’s robots.txt spec says a crawler uses “the group with the most specific user agent that matches,” and “only one group is valid for a particular crawler.” So if the same file also has a
User-agent: Googlebotgroup with looser rules, Googlebot follows that group and ignores your disallow all.
One character away from allow all
The most common robots.txt accident is the empty disallow. Google’s spec says “crawlers ignore rules without a [path],” so Disallow: with nothing after it blocks nothing. It’s the classic way to write “allow everything,” which means the two files below look nearly identical and do opposite things.
Disallow: /
Disallow:
If you want to allow everything, the clearest options are Allow: / or no robots.txt file at all. Google’s robots.txt report help says not having the file is fine, because Google can then crawl all URLs. Before you upload either version, run your key URLs through a parser as shown in our robots.txt testing guide.
Disallow all doesn’t remove you from Google
This is the exception that matters most. Blocking crawling and blocking indexing are different jobs. Google’s robots.txt introduction says robots.txt “is not a mechanism for keeping a web page out of Google,” and that a blocked URL can still show up in results, without a description, if other pages link to it.
In Search Console that shows up as “Indexed, though blocked by robots.txt” in the Page indexing report. Google’s fix for pages you want gone is to “remove the robots.txt block and use ‘noindex’,” because a crawler that can’t fetch a page never sees the noindex tag on it. Our robots.txt noindex article covers that swap in detail, and the Page indexing report guide explains the other statuses you’ll see.
WordPress learned the same lesson. Its “Discourage search engines from indexing this site” box used to write Disallow: / into robots.txt. Since WordPress 5.3 it prints a noindex,nofollow robots meta tag instead, because, as the core team put it, a blocked site can still be listed. See our WordPress robots.txt guide if your site runs on it.
Disallow all is not security either. RFC 9309 says plainly that the rules “are not a form of access authorization.” Well-behaved crawlers obey it, while scrapers and bad bots can ignore it, and anyone can read your robots.txt to see which paths you’re hiding.
When disallow all is the right call
The pause case deserves a closer look, because it’s where small businesses get hurt. Google’s guidance on pausing a site says to “continue to allow crawling through the robots.txt file,” and warns that “there’s no fixed time for a recovery from a complete removal.” If you must take the whole site offline for a day or two, it recommends a 503 error page, and it warns against returning a 503 for robots.txt itself, “because this blocks all crawling.” Say a made-up accounting firm closes for two weeks after tax season. The better move is to leave the site up with a banner about the dates, not to block crawlers.
The rules you probably want instead
Most people searching for “disallow all” want something slightly narrower. These three come straight from Google’s useful rules page.
Allow: /
User-agent: *
Disallow: /
Disallow: /
User-agent: *
Allow: /
Disallow: /
Allow: /public/
The third one works because Google picks the most specific matching rule by path length, so Allow: /public/ beats Disallow: / for URLs in that folder. When an allow and a disallow are equally specific, Google’s spec says it uses “the least restrictive rule.” If you’re trying to keep AI bots out while staying in Google, don’t use disallow all at all. Name each bot in its own group, as our AI crawler guide lists them.
How to undo a disallow all on a live site
If a launch or migration carried the staging file over to production, fix it in this order:
- Replace the file. Remove
Disallow: /from theUser-agent: *group, or delete the file, and loadyourdomain.com/robots.txtin a browser to confirm the live version changed. Clear any CDN or caching plugin first if it still shows the old one. - Check it doesn’t return a server error. Google treats a 4xx robots.txt (except 429) as if no file exists, but on a 5xx it stops crawling the site for the first 12 hours and can fall back on the last cached copy, your disallow all, for up to 30 days.
- Ask Google to re-read it. In Search Console, open the robots.txt report (it lives in Settings), click the three-dot menu next to the file and choose “Request a recrawl.” Google says it caches robots.txt “for up to 24 hours,” so this mainly saves you part of that wait.
- Request indexing for your most important pages with URL Inspection, keeping in mind Google’s note that there’s a quota for individual URLs.
- Resubmit your sitemap so Google rediscovers everything else. Google’s recrawl guide says crawling “can take anywhere from a few days to a few weeks,” and that asking again for the same URL won’t speed it up.
Step 2 is the one people skip. A robots.txt that errors after the fix can keep the old block in force for weeks, so check the status code, not just the text on screen. For a broader post-launch check, our guide to getting a site indexed walks through the rest.
FAQ
Does Disallow: / block every bot?
It blocks any crawler that follows the robots.txt standard and has no more specific group of its own in your file. Crawlers that ignore the standard aren’t stopped, because robots.txt is a request, not access control.
How do I disallow all crawlers except Google?
Add a User-agent: Googlebot group with Allow: / above a User-agent: * group with Disallow: /. Googlebot follows its own named group, and every other compliant bot falls back to the wildcard block.
How long does it take Google to recover after I remove a disallow all?
Google usually picks up the new file within a day, since it caches robots.txt for up to 24 hours. Recrawling the pages themselves can take days to weeks, and Google gives no fixed recovery time if the site had already dropped out.
Keep the block off production
Disallow all is a staging tool, and even there it should sit behind a password. On a live site, block only the folders or bots you mean to, use noindex for pages that must leave the index, and add “check robots.txt” to every launch and migration checklist so the two-line rule never ships by accident.
