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
Deleted or moved page without a redirect
Typo in the URL or link
Incorrect API endpoint path
Missing file (image, CSS, JS) on the server
Broken internal or external links
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:
401 Unauthorized Error
Learn what a 401 Unauthorized error means, common causes, and how to fix authentication failures in your web applications.
403 Forbidden Error
Learn what 403 Forbidden means, how it differs from 401, and how to fix access denied errors in your applications.
429 Too Many Requests Error
Learn what 429 Too Many Requests means, how rate limiting works, and how to handle or avoid hitting API rate limits.
500 Internal Server Error
Learn what 500 Internal Server Error means, common causes, and how to debug and fix server-side failures.
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.