DEV Community

linkbruno.com
linkbruno.com

Posted on

How to fix "Not found (404)" errors in Google Search Console

Open Google Search Console, go to Indexing > Pages, and there it is: Not found (404), sometimes with hundreds of URLs. It looks alarming. Most of the time it isn't, but a few of those URLs usually are worth fixing, and the trick is telling them apart quickly.

This guide walks through the report, how to decide what to do with each URL, and how to confirm the fix.

First: 404s are not a penalty

A 404 is the correct answer for a page that doesn't exist. Google has said for years that 404s on their own don't hurt the rest of your site's rankings. The report exists so you can spot URLs that should work but don't.

So the goal is not "zero 404s". The goal is:

  • no 404s on URLs that real people or real links still use
  • no internal links on your own site pointing to 404 pages
  • no 404 URLs in your sitemap

Step 1: Export the list

In Indexing > Pages, scroll to "Why pages aren't indexed" and click Not found (404). Use the export button at the top right to download the examples as a CSV or Google Sheet.

The list shows up to 1,000 example URLs and the date Google last crawled each one. Sort by "Last crawled" so recent problems come first.

Step 2: Sort the URLs into buckets

Skim the export and group the URLs. Nearly every 404 falls into one of these:

Bucket Example Usual action
Moved page /blog/old-slug now lives at /blog/new-slug 301 redirect
Deleted on purpose discontinued product, expired event leave as 404 or 410
Typo in an internal link /pricng fix the link
Junk or spam URLs /?p=123abc, random strings ignore
Old URL structure /index.php?page=about after a migration redirect pattern
In your sitemap sitemap still lists a removed page remove from sitemap

Junk URLs, often created by spam sites linking to made-up paths, can be ignored. Google will crawl them less over time.

Step 3: Find who links to each URL

For the URLs that look important, find out where Google found them. Paste one into the URL Inspection bar at the top of Search Console. In the result, expand Page indexing and look at Discovery: it lists the sitemaps and a referring page, if Google has one.

  • If the referring page is on your site, that's an internal broken link. Fix the link itself, not just the destination.
  • If it's another site, the URL has a backlink. That's a strong reason to redirect it.
  • If it's your sitemap, regenerate or edit the sitemap.

Search Console only shows a sample. To find every internal page that links to a 404, run a crawl of your site with a broken link checker, which lists the source page for each broken link.

Step 4: Apply the right fix

Redirect moved pages with a 301

If there is a clear replacement, redirect the old URL to it. Send it to the closest match, not to the homepage. Google treats a redirect to an irrelevant page, especially the homepage, much like a soft 404.

nginx:

location = /blog/old-slug {
    return 301 /blog/new-slug;
}

# a whole old section
rewrite ^/news/(.*)$ /blog/$1 permanent;
Enter fullscreen mode Exit fullscreen mode

Apache (.htaccess):

Redirect 301 /blog/old-slug /blog/new-slug
RedirectMatch 301 ^/news/(.*)$ /blog/$1
Enter fullscreen mode Exit fullscreen mode

Netlify (_redirects file) or Cloudflare Pages:

/blog/old-slug   /blog/new-slug   301
/news/*          /blog/:splat     301
Enter fullscreen mode Exit fullscreen mode

Next.js (next.config.js):

module.exports = {
  async redirects() {
    return [
      { source: '/blog/old-slug', destination: '/blog/new-slug', permanent: true },
    ];
  },
};
Enter fullscreen mode Exit fullscreen mode

Let deleted pages stay deleted

If a page is gone and there's no good substitute, a 404 (or 410) is fine. Just make sure nothing on your own site still links to it and it's not in your sitemap.

Fix internal links at the source

A redirect hides an internal broken link but doesn't fix it. Update the link in your content, menu or template so it points at the live URL directly. That saves a redirect hop for every visitor and every crawl.

Step 5: Check your work before validating

Before telling Google you've fixed anything, test the URLs yourself:

while read -r url; do
  printf '%s  %s\n' "$(curl -s -o /dev/null -w '%{http_code} -> %{url_effective}' -L "$url")" "$url"
done < urls.txt
Enter fullscreen mode Exit fullscreen mode

Each line shows the final status and where the URL ended up. You want 200 on the redirect target, or a deliberate 404/410 for removed pages.

Step 6: Click "Validate fix"

Back in the Not found (404) report, click Validate fix. Google re-crawls the affected URLs over the next days or weeks. The status moves to "Passed" for URLs that now resolve, and "Failed" for any that still return 404.

Don't worry if deliberate 404s keep the validation from passing. That's expected. The report is a to-do list, not a score.

Prevent the next batch

Most 404 reports come from the same few events: a redesign, a CMS migration, a changed slug, a removed product category. Before any of those:

  1. Export a list of your current URLs from the sitemap.
  2. Map each old URL to its new home.
  3. Ship the redirects with the change, not afterwards.
  4. Crawl the site right after launch.

If you'd rather not remember to re-crawl, linkbruno.com checks a site's links on a schedule and emails you when one breaks, with the page it's on. Either way, catching a broken link the week it appears beats finding it in Search Console months later.

Top comments (0)