Error Encyclopedia
404

404 Not Found Error

Learn what 404 Not Found means, common causes, and how to fix broken links and missing resources on your website or API.

What Does This Error Mean?

The 404 Not Found status code indicates the server cannot find the requested resource. This could mean a broken link, a removed page, a mistyped URL, or an incorrect API endpoint path.

Common Causes

1

Deleted or moved page without a redirect

2

Typo in the URL or link

3

Incorrect API endpoint path

4

Missing file (image, CSS, JS) on the server

5

Broken internal or external links

6

Server misconfiguration (e.g., missing rewrite rules)

How to Fix It

Implement custom 404 pages

Create a user-friendly 404 page that helps visitors find what they need.

// Next.js custom 404 page
// app/not-found.tsx
export default function NotFound() {
  return (
    <div>
      <h1>404 — Page Not Found</h1>
      <p>The page you're looking for doesn't exist.</p>
      <Link href="/">Go Home</Link>
    </div>
  )
}

Set up redirects for moved content

When you move or delete pages, set up 301 redirects to the new location.

# Nginx redirect
rewrite ^/old-page$ /new-page permanent;

# Next.js redirects in next.config
module.exports = {
  async redirects() {
    return [
      { source: "/old-page", destination: "/new-page", permanent: true },
    ]
  }
}

Check file paths

Verify that file references in your code point to the correct paths, especially after restructuring directories.

// ❌ Wrong path
<img src="images/photo.jpg" />

// ✅ Correct path (with leading slash for absolute)
<img src="/images/photo.jpg" />

Related Tools

Use these tools to debug and fix this error:

Related Guides

Deepen your understanding with these guides and tutorials:

Related Errors

Other common errors in this category:

Frequently Asked Questions

Should I redirect 404s to the homepage?

No. Redirecting all 404s to the homepage is bad for SEO. Instead, serve a helpful 404 page with navigation options or set up specific 301 redirects for moved content.

How do I find broken links on my site?

Use Google Search Console, a crawler like Screaming Frog, or an SEO tool to find 404 errors. The Coverage report in Search Console shows which URLs return 404.