6 min read
Google indexed my staging site - how do I get it out of the index?
By CrawlWarden, which builds the monitoring described at the foot of this article.
Published .
Do two things, in order. Use the Search Console Removals tool on the staging property to hide the URLs within a day, remembering that the hide lasts about six months. Then make it permanent by requiring authentication, or by returning 404 or 410. Do not reach for robots.txt: Google says "Don't use robots.txt as a way to block your page", because a disallowed URL can still be indexed and a crawler that cannot fetch the page will never see a noindex on it.
Today: hide it, before you fix it
The Removals tool is the fast path, and Google is precise about what it does: it will "remove a page hosted on your site from Google's search results within a day", and "Requests made in the Removals tool last for about 6 months" (Remove a page hosted on your site from Google). It hides. It does not remove. Do nothing else and the staging URLs return when the six months are up.
Verify the staging hostname as its own Search Console property first. A property for www.example.com does not cover staging.example.com, and a removal request filed on the wrong property does nothing at all.
Why robots.txt is exactly the wrong tool here
This is the first instinct almost everyone has, and it is the one Google warns against by name in the removal documentation: "Don't use robots.txt as a way to block your page." Two separate mechanics sit behind that sentence.
- Disallow blocks crawling, not indexing. A URL nobody is allowed to fetch can still be indexed from links alone, which is how a staging host with a single inbound link ends up listed with no description under it.
- A crawler that cannot fetch the page cannot read a directive on it. Google puts it in one sentence: "If the page is blocked by a robots.txt file or the crawler can't access the page, the crawler will never see the
noindexrule, and the page can still appear in search results" (Block search indexing with noindex).
Then: make the removal permanent
Three of the four options below work. The fourth is the one most people reach for first. And if a noindex is already in place with a Disallow added on top of it, remove the Disallow: that combination freezes the current state by making the directive unreadable, which is the opposite of what either was meant to do.
| Option | What it does | When it is the right one |
|---|---|---|
| Require authentication | Google: "Limiting access to your page enables the right users to view your page, while preventing Googlebot and other web crawlers from accessing it." | Almost always, for a non-production environment. It is the only option here that also stops Bing, archivers and scrapers, and the only one a deploy cannot quietly undo. |
noindex meta tag or X-Robots-Tag | Drops the page on the next crawl of it, and only if the crawler can reach the page to read the directive. | A preview environment that genuinely has to stay publicly reachable for clients. |
404 or 410 | URLs already indexed that start returning a 4xx are removed from the index. | The environment is being retired rather than kept. |
Disallow in robots.txt | Blocks crawling. Removes nothing, and hides any noindex you add afterwards. | Never, for this problem. |
How it got indexed when nobody linked to it
"Nobody knows the URL" has not been a security model for a long time. Treat a reachable staging host as a public one, because it is one.
- A link from production. A staging URL left in a footer, a canonical tag, a sitemap entry or an absolute asset path that survived a database copy.
- The sitemap itself. A sitemap generated on staging lists staging URLs, and then gets deployed or submitted.
- Certificate Transparency. Every certificate issued for a hostname is written to public, append-only logs, and "anyone can query them to see what certificates have been included and when" (How CT works). Issue a certificate for
staging.example.comand the hostname is public the same day, whoever you told. - Everything else that reports URLs: browser features, analytics scripts, link shorteners, and anyone who pasted a staging link into a public validator.
The failure that runs the other way, and costs more
An indexed staging site is embarrassing. The expensive version of the same root cause is staging configuration reaching production: the site-wide noindex that lived on the preview environment, promoted with everything else in a release, quietly removing the real site from search. That is the single most common way a live page goes noindex, and it is one environment's settings travelling forward with the code.
robots.txt does the same thing more slowly. A staging Disallow: / shipped to production does not deindex the site on contact, which makes it harder to spot rather than easier: pages stay listed while their descriptions disappear, and traffic drains over weeks.
Keeping it from happening again
- Put authentication in front of every non-production environment, at the edge rather than in the application, so a broken deploy cannot expose it.
- Drive robots directives from the environment, and assert on them in CI. A production build that emits
noindexshould fail before it ships. - Grep the build output for the staging hostname. That catches most stray canonicals, sitemap entries and absolute asset URLs in one step.
- Monitor the production URLs for the directives themselves, so a change announces itself on the day rather than turning up in a report three weeks later.
The checks that report this
CrawlWarden watches a list of URLs you choose and reports what changed. It does not diagnose and it does not score. Severity is a property of the check rather than a setting: the number below is how many consecutive runs must see the new value before it becomes an email, and it is never less than two, because one observation is noise.
robots meta tagconfirmed over 2 consecutive runs
Reads the robots meta tag on every fetch and reports any change to it. A staging default arriving on a production URL is the case this exists for.
X-Robots-Tagconfirmed over 2 consecutive runs
The header version of the same directive. It carries identical weight and never appears in the HTML, so it is the one people miss.
robots.txt contentconfirmed over 2 consecutive runs
Any edit at all, whether or not it changes the verdict for a URL you watch. One line in this file has the largest blast radius on a site.
HTTP status codeconfirmed over 2 consecutive runs
Reports when a watched URL stops returning the status it used to, which is how an accidental redirect or an authentication wall on the wrong host shows up.
Every check is available on every plan, including the free one. CrawlWarden pricing, per site rather than per URL.
Questions
- How long does it take Google to drop staging URLs?
- The Removals tool hides them within a day. An actual deindex happens on the next crawl of each URL, and Google notes that "it may take months for Googlebot to revisit a page" depending on how important it considers the page. A staging host is not important.
- noindex or password protection?
- Authentication, where you can. It is the stronger of the two because it does not depend on a crawler reading and obeying a tag, and it covers every other bot at the same time. Use noindex only where the environment has to stay publicly reachable.
- Does an indexed staging site hurt the production site?
- Not as a penalty. It is a canonicalisation problem: two hosts serving the same content, with Google choosing between them. The realistic worst case is Google preferring the wrong host for a while. Removing the staging host settles it.
- Can CrawlWarden find indexed staging URLs for me?
- No. It watches a list of URLs you give it. Add the staging host and it will report when its directives or status codes change, but it does not search the index for stray hostnames. A
site:query and a look through your certificate transparency log does that job better.
Related
Sources
What was checked, and where. An entry with no link is something that could not be verified, named here rather than left out.
Google Search Central: Remove a page hosted on your site from Google
The Removals tool removing a page within a day, the six-month duration, the permanent options including limiting access, and the instruction not to use robots.txt to block a page.
Google Search Central: Block search indexing with noindex
That a crawler blocked by robots.txt never sees the noindex rule, and that a revisit can take months.
Google Search Central: HTTP status codes and network errors
That indexed URLs returning 4xx are removed from the index.
Certificate Transparency: How CT works
That certificates are published to public append-only logs anyone can query, which is why a staging hostname becomes public on the day its certificate is issued.
Not verified: search volume for this query
No keyword volume tool was available. Demand was judged from the live US SERP, which carries no ads and ranks two Google Help forum threads, Reddit and Stack Overflow on page one.
Know the moment this happens to you
Give CrawlWarden a domain, keep the pages it suggests, and the first check runs immediately. Free forever for one site.