404 Not Found: what it means, when it's fine and how to fix the ones that matter

, Founder · Updated

A 404 Not Found error means the server has no page at the URL that was requested, or won't say whether it has one. Most 404s need no fix at all. The ones that matter are broken links on your own site, pages that moved without a redirect, and "not found" pages that wrongly return a 200 status.

The HTTP specification defines it this way: "The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists." It adds that a 404 "does not indicate whether this lack of representation is temporary or permanent" (RFC 9110, section 15.5.5).

When a 404 is the right answer

A 404 is correct, and harmless, in these cases:

  • You deleted a page and nothing replaces it. Google's Search Console help says "404 responses are not necessarily a problem, if the page has been removed without any replacement" (Page indexing report).
  • Someone mistyped a URL or linked to one that never existed. You can't control other sites' typos.
  • Bots probe for files you don't have, such as /wp-login.php on a site that isn't WordPress.
  • A private resource should stay hidden. RFC 9110 lets a server that wants to hide a forbidden resource "respond with a status code of 404 (Not Found)" instead of 403 (section 15.5.4).

When a 404 needs fixing

SituationWhat to do
A page moved to a new URL301 redirect the old URL to the new one (301 vs 302)
Your own pages link to the missing URLUpdate or remove the internal links
The URL is listed in your sitemapRemove it from the sitemap, or restore the page
Other sites link to it and a close replacement exists301 redirect to that replacement
The page is gone for good and you want that statedReturn 410 Gone
The URL should exist but returns 404A routing, rewrite or deployment bug. Fix the route

For moved pages, Google's advice is direct: "If your page has moved, use a 301 redirect to the new location" (Search Console help). Don't send every dead URL to the homepage. A redirect only helps when the target answers the same need.

Soft 404s: the version that does cause trouble

A soft 404 is a page that tells the visitor nothing is there but returns 200 OK. Google's documentation says that if a 2xx page's content suggests "an error for Google Search, an empty page or an error message", Search Console will show a soft 404 error (Google Search Central). Typical causes are a product template that prints "Product not found", an empty search result page, or a single-page app that shows its own "not found" screen without telling the server.

Check the real status code from the command line:

curl -s -o /dev/null -w "%{http_code}\n" https://example.com/this-page-does-not-exist

Anything other than 404 or 410 for a URL that doesn't exist is worth fixing.

Single-page apps

When routing happens in the browser, the server has already sent a 200 by the time the app decides the page doesn't exist. Google's JavaScript SEO guide gives two ways out: "Use a JavaScript redirect to a URL for which the server responds with a 404 HTTP status code (for example /not-found)", or "Add a <meta name="robots" content="noindex"> to error pages using JavaScript" (JavaScript SEO basics).

How to return a proper 404, by platform

nginx

nginx returns 404 for files it can't find. To serve your own page while keeping the status, use error_page with a local URI:

error_page 404 /404.html;

That example comes from the nginx core module docs. If nginx proxies to an application that sends its own 404s, those pass through unless proxy_intercept_errors is on (proxy module).

Apache

ErrorDocument 404 /404.html

Use a local path, not a full URL. Apache's documentation warns that an ErrorDocument pointing at a URL with http in front makes the server send a redirect, so "the client will not receive the original error status code, but instead will receive a redirect status code" (Apache core docs). That turns a clean 404 into a redirect to a 200 page, which is the soft 404 pattern again.

Next.js (App Router)

Call notFound() when a record doesn't exist. Next.js documents that it "throws an error that renders a Next.js 404 page" and that it "also injects a <meta name="robots" content="noindex" /> tag so the page is not indexed" (Next.js docs):

import { notFound } from 'next/navigation'

export default async function Product({ params }) {
  const { slug } = await params
  const product = await getProduct(slug)
  if (!product) notFound()
  // ...
}

One catch from the same page: if the response has already started streaming from a <Suspense> boundary when notFound() runs, the response "keeps its 200 status" and gets the noindex tag instead. Run the existence check before streaming starts if you want a real 404 status.

Cloudflare

Cloudflare says it "does not generate 404s for customer websites, we only proxy the request from the origin server" (Cloudflare error 404). A 404 on a site behind Cloudflare comes from your origin, so fix it there.

How to find the 404s that matter

  1. Search Console. The Page indexing report lists "Not found (404)" URLs Google tried to crawl. Sort by the ones you recognise as real pages.
  2. Your logs. Filter server or CDN logs for status 404 and look at the referrer. A 404 with a referrer from your own domain is a broken internal link.
  3. Your sitemap. Every URL in it should return 200. Check yours with the sitemap checker.
  4. Redirect targets. Make sure old redirects don't end in a 404. The redirect checker follows each hop and shows the final status code.

How Google Search treats a 404

Google's documentation groups 404 with the other client errors: "Google doesn't index URLs that return a 4xx status code", "URLs that are already indexed and return a 4xx status code are removed from the index", and "Newly encountered 404 pages aren't processed." Crawling of those URLs "gradually decreases" (Google Search Central).

A 404 doesn't slow down crawling of the rest of your site. The same page says "the 4xx status codes, except 429, have no effect on crawl rate." The cost of a 404 is limited to the URL itself, plus any links pointing at it that now lead nowhere.

For every status code and how Google handles it, see HTTP status codes.

Questions

Do 404 errors hurt SEO?
Not by themselves. Google's Search Console help says 404 responses are not necessarily a problem if the page was removed without a replacement. A 404 takes that one URL out of the index; it doesn't penalize the rest of the site. Fix 404s you link to yourself or list in your sitemap, and redirect pages that moved.
Should I redirect every 404 to my homepage?
No. Redirect a missing URL only when there is a page that replaces it. Sending every dead URL to the homepage gives visitors a page they didn't ask for, and a page that doesn't match the request can be reported as a soft 404 anyway.
What is a soft 404?
A page that says 'not found' or shows nothing useful but returns a 200 status code. Google can detect this and reports it as a soft 404 in Search Console. Fix it by returning a real 404 or 410 status for pages that don't exist.
What is the difference between 404 and 410?
404 says nothing is at the URL and doesn't say whether that is permanent. 410 says the resource is gone and the condition is likely permanent. Google's documentation treats all 4xx codes except 429 the same way, so pick the one that is accurate.
How do I find the 404s on my site?
Open Search Console's Page indexing report and look at 'Not found (404)'. Check your server or CDN logs for 404 responses with internal referrers, and crawl your own site to find links that point at missing pages.

Related

See where you stand in Google and AI answers

Starter is $19 a month for one site, with a 14-day free trial and no card to start.