Fixes

How to find and fix 404 errors and broken links (and which ones to ignore)

To fix 404 errors, first sort them by cause: correct broken links on your own pages, add a 301 redirect for pages that moved, and leave deleted pages returning 404 or 410. Google says 404s do not harm indexing or ranking, so ignore bot junk. Then confirm a missing URL really returns 404, not 200, so it is not a soft 404.

Do 404 errors hurt your site in Google?

Not by themselves. Google's Search Console help page on 404 errors says plainly that 404s don't harm your site's indexing or ranking, and that you can safely ignore them if you are certain the URLs should not exist. A page that is gone and returns 404 is the web working as designed. Google drops those URLs from its index over time and crawls them less often, according to its HTTP status code guide.

The 404s that do cost you are a smaller set:

So the job is not to get the Search Console count to zero. It is to sort 404s by where they came from, fix the ones that break a real path for a person, and leave the rest alone.

Where do 404s come from, and what should you do with each?

Every 404 has one of a handful of causes, and each cause has one correct response. Guessing wrong in either direction causes problems: leaving a moved page unredirected loses its visitors, while redirecting everything to your home page creates soft 404s (covered below). Use this table to decide:

Where the 404 comes fromHow you spot itWhat to doStatus to return
Typo or stale path in a link on your own siteLink checker on your build or live siteFix the link in the sourceThe target's normal 200
Page renamed or movedOld URL in Search Console, analytics, or your git historyRedirect old URL to new URL301 or 308
Page deleted, nothing similar existsYou removed it on purposeLeave it; remove links and sitemap entries pointing to it404 or 410
Another site links to a misspelled or old URLSearch Console shows the URL; referrer in analyticsRedirect to the matching page if one exists301 or 308
URL in your sitemap that no longer existsSearch Console Page indexing reportRestore the page or drop it from the sitemap200 or 404
Bots probing paths like /wp-login.php on a site that is not WordPressOdd URLs nobody ever linked toNothing404

Source: rules from Google's 404 errors help page and crawling errors troubleshooting guide.

A note on 404 versus 410: Google says it currently treats a 410 (Gone) the same as a 404 (Not found). A 410 states your intent more clearly to other clients, but if your host makes it awkward to send one, a 404 loses you nothing in Google Search.

Check two places: the files you are about to deploy, and what Google has already seen. The first catches mistakes before anyone hits them. The second catches old URLs other people still link to.

Check your build folder before you deploy

Most of the guides that rank for this search send you to a paid crawler or a WordPress plugin. For a static or generated site you can check every internal link offline in under a second with Python's standard library. Save this as check_links.py in your project:

#!/usr/bin/env python3
"""Find broken internal links in a built static site folder."""
import sys
from pathlib import Path
from html.parser import HTMLParser
from urllib.parse import urlsplit, unquote

root = Path(sys.argv[1] if len(sys.argv) > 1 else "dist").resolve()

class Links(HTMLParser):
    def __init__(self):
        super().__init__()
        self.found = []
    def handle_starttag(self, tag, attrs):
        for name, value in attrs:
            if name in ("href", "src") and value:
                self.found.append(value)

def target_exists(page, link):
    parts = urlsplit(link)
    if parts.scheme or parts.netloc or not parts.path:
        return True  # external, mailto:, tel:, or #fragment only
    path = unquote(parts.path)
    base = root if path.startswith("/") else page.parent
    t = (base / path.lstrip("/")).resolve()
    return t.is_file() or (t / "index.html").is_file() or t.with_suffix(".html").is_file()

broken = 0
for page in sorted(root.rglob("*.html")):
    p = Links()
    p.feed(page.read_text(errors="ignore"))
    for link in p.found:
        if not target_exists(page, link):
            broken += 1
            print(f"{page.relative_to(root)}: {link}")
print(f"{broken} broken internal link(s)")
sys.exit(1 if broken else 0)

Then run it against your output folder (dist, public, _site, or out, depending on your generator):

python3 check_links.py dist

Each broken link prints as the page it is on, followed by the link itself, for example blog/post/index.html: ../nope.html. That tells you exactly which source file to open. The script resolves both root-relative links like /about/ and relative ones (../about/), accepts /about when about.html or about/index.html exists, and checks src attributes too, so missing images and scripts show up. It exits with code 1 when anything is broken, which matters for the CI step later.

What it does not do: follow external links, run JavaScript, or know about redirects you set up in your host's config. A link to an old path that your host redirects will be reported as broken. That is useful, since linking straight to the final URL saves visitors a hop, but expect it.

Check what Google has found

  1. Open Search Console, go to Indexing then Pages, and open the Not found (404) row under the reasons pages are not indexed.
  2. Export the list and sort it against the table above. Anything you recognize as a page that moved gets a redirect. Anything that looks like a probe from a bot gets nothing.
  3. For a URL you are unsure about, use the URL Inspection tool to see where Google found it. A referring page on your own site means a broken internal link; fix that first.
  4. After you fix or redirect a batch, give it time. Google says the report should stop showing a 404 after about a month.

How do you fix 404s on Netlify and Vercel?

Fixing a broken internal link means editing the link. Fixing a moved page means a redirect at the host, so it works before any HTML loads. Here is the exact syntax for the two most common hosts for small sites.

Netlify: the _redirects file

Put a plain text file named _redirects in your publish folder. Each rule is one line: old path, new path, and an optional status. Netlify's redirect options documentation says the default status, if you leave it off, is 301.

# Single page moved
/pricing-2024      /pricing/        301

# Whole section renamed: /news/anything goes to /blog/anything
/news/*            /blog/:splat     301

# Per-language 404 pages
/en/*              /en/404.html     404

Three rules from Netlify's redirects overview catch people out. Rules are read top to bottom and the first match wins, so put specific rules above broad ones. Rules in _redirects run before rules in netlify.toml. And Netlify matches paths with or without a trailing slash, so you do not need two rules per URL. Netlify's status list does not include 410; as noted above, a 404 is treated the same by Google.

If you prefer config in netlify.toml, the same moved page looks like this:

[[redirects]]
  from = "/pricing-2024"
  to = "/pricing/"
  status = 301

Vercel: vercel.json

Vercel reads redirects from a redirects array in vercel.json. Per Vercel's configuration redirects docs, permanent: true (the default) returns a 308 and permanent: false returns a 307. Google treats 308 the same as 301, so either is fine for a permanent move.

{
  "redirects": [
    { "source": "/pricing-2024", "destination": "/pricing", "permanent": true }
  ]
}

If you need a specific code instead, use statusCode in place of permanent; the two cannot be combined in one rule. Vercel caps the array at 2,048 redirects, which only matters on large migrations.

Whichever host you use, point each old URL straight at the final page. If /a redirects to /b and /b already redirects to /c, change the first rule to go to /c. Google's crawlers follow up to 10 hops, but every hop is another round trip for the visitor.

Is your 404 page actually returning a 404?

This is the check almost nobody runs, and it is the one that turns a harmless missing page into a real problem. If a missing URL shows a friendly error message but the server sends 200 OK, Google calls it a soft 404. Its crawling errors guide calls this a bad user experience, and Search Console reports these URLs separately.

Test it in one command. Request a path that cannot exist and print only the status code:

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

You want 404. If you get 200, look for these causes, in this order:

  1. A single-page app catch-all. A rule like /* /index.html 200 in Netlify's _redirects serves your app shell for every unknown path, with a 200. Your router then shows a "not found" view, but the status is already sent. Prerender real routes, or have the app's not-found route served from a path your host returns as 404.
  2. A redirect to the home page. Some plugins and templates send every missing URL to /. Google's 404 help page tells you not to redirect 404s to your home page; the visitor gets no explanation and Google sees an irrelevant target.
  3. A server-rendered error view that forgets to set the status. In a framework route handler, make sure the not-found branch sets 404 rather than only rendering an error template.

On Netlify, a plain static site gets this right for free: add a 404.html file at the root of your publish folder and Netlify shows it for any path that does not match a file, with no redirect rule needed. Make that page useful. Say clearly that the page was not found, link to your home page and your most visited sections, and include a search box if you have one. MDN's 404 reference covers the status code itself if you need to explain it to a client.

What should you not do when fixing 404s?

Each of these looks like a fix and makes things worse:

For the full order of what to check on a small site, including where 404s sit relative to indexing and HTTPS problems, see our website audit checklist for small sites.

Broken internal links almost always arrive with a change: a renamed page, a new nav item, a deleted post that three others linked to. So check at the moment of change, not once a quarter.

  1. Run the checker in your build. Because check_links.py exits with code 1 on any broken link, chaining it after your build command makes a broken link fail the deploy. For example: npm run build && python3 check_links.py dist. If your build environment has no Python, run the same command in a CI job before merging.
  2. Add the redirect in the same commit as the rename. When you move a page, put the _redirects or vercel.json line in that commit. Your git history then shows every URL change next to its redirect.
  3. Look at Search Console monthly. New entries in the Not found (404) list are usually old URLs other sites still use. Redirect the ones that match a real page.
  4. Check outbound links occasionally. Pages you link to move too. A crawler that follows external links, or a quick pass with curl -sI on your most important outbound links, covers this.

If you work with an AI coding agent, this is a good task to hand over, as long as you review the proposed redirects before they ship; our guide to running a technical SEO audit with Claude Code covers how to check its work. CrawlKind does this as part of a full audit, listing each broken link with the page it was found on and proposing the redirect or link fix for you to approve; the sample audit shows what that looks like.

Sources

Frequently asked questions

Do 404 errors hurt SEO?

Not on their own. Google's Search Console help says 404s don't harm your site's indexing or ranking. They matter when they come from broken links on your own pages, from moved pages with no redirect, or from URLs listed in your sitemap, because those break a path a visitor or Google was told to follow.

Should I redirect all 404 pages to my home page?

No. Google's 404 help page specifically says not to redirect 404s to your home page. Visitors land somewhere unrelated with no explanation, and Google may treat the redirect as a soft 404. Redirect only to a page with the same or clearly equivalent content, and let the rest return 404.

Is a 410 better than a 404 for deleted pages?

Google says it currently treats 410 (Gone) the same as 404 (Not found), so there is no Search benefit either way. Use 410 if your host supports it and you want to state that removal is permanent. On Netlify, whose redirect docs do not list 410, a plain 404 works just as well.

How long until fixed 404s disappear from Search Console?

Google says the 404 report should stop showing a URL after about a month once it is no longer linked or submitted. A redirect is picked up the next time Google crawls the old URL, which for rarely visited URLs can take weeks, so check back monthly rather than daily.

What is a soft 404 and how do I test for one?

A soft 404 is a missing page that shows an error message but sends a 200 OK status. Test it by requesting a made-up path with curl and printing the status code. If you see 200 instead of 404, check for a single-page app catch-all rule or a redirect-everything-home plugin.

Audit your site with your AI coding agent

CrawlKind is a website audit and fix kit for Claude Code: a full crawl, a prioritized findings report, and proposed fixes you review before anything changes. $49 once.

See a sample audit

Checkout isn't open yet.

CrawlKind is being finished and tested before it goes on sale at $49, paid once. Nothing is charged today. Leave an email if you want one message when the kit ships. No newsletter, no follow-ups.

That email doesn't look right. Check for typos.One email when CrawlKind is available. Nothing else.

Saved. You'll get one email when the kit is ready.

Kevin Glover

@gloverbuilds

I ship small products in public. Building toward $1M with SideRoad.

● Built by @gloverbuilds