Common causes
- A typo in the URL, or the wrong case: on most Linux servers
/Aboutand/aboutare different paths. - The page was moved or deleted without a redirect from the old URL.
- A single-page app only works from the homepage: client-side routes such as
/dashboardreturn 404 on refresh or a direct visit because the server has no file at that path. - A missing or extra trailing slash, or a wrong base path after deploying the app to a subfolder.
- A file referenced by its build hash, such as
main.3f9a.js, no longer exists after a new deploy, while a cached page still asks for it. - For APIs: a wrong base URL or version prefix such as
/api/v1, or an ID that doesn't exist.
Debugging steps
- Copy the exact URL from your browser's network tab and check its case, slashes and encoded characters.
- Find out who answered. Response headers such as
server,cf-rayorx-vercel-idshow whether the 404 came from a CDN, a proxy or your application. - Check that the route or file exists in what was actually deployed, not just in your local project.
- For an API, call the same URL with curl and compare it with the routes the framework lists.
Fix 404s on refresh in single-page apps
Tell the server to answer unknown paths with the app's index.html, so the client-side router can handle them:
# nginx
location / {
try_files $uri $uri/ /index.html;
}
# Apache (.htaccess)
FallbackResource /index.html404s and SEO
- 404s for URLs that never existed don't hurt the rest of your site. Search engines expect them.
- When a page has moved, redirect the old URL to the new one with a 301 so visitors and ranking signals follow.
- When a page is gone for good, a 404 or a 410 Gone is correct. Don't redirect everything to the homepage instead.
- A custom "page not found" page must still return the status 404. If it returns 200, Google reports it as a soft 404.
Frequently asked questions
What is the difference between 404 and 410?
404 says nothing is at that URL, without saying whether it's permanent. 410 Gone says it was removed on purpose and won't come back. Search engines drop both from their index; a 410 can be dropped slightly sooner.
What is a soft 404?
A page that tells visitors it doesn't exist, or has almost no content, but returns 200 OK. Search engines treat it as missing anyway and report it as an error. Return a real 404 status, or give the page useful content.
Should an API return 404 or an empty list?
Return 200 with an empty list when a search or collection has no results. Return 404 when a specific resource, such as /users/42, doesn't exist.
More http status code lookup guides
- 502 Bad Gateway: What It Means and How to Fix It
- 504 Gateway Timeout: Causes and Fixes
- 429 Too Many Requests: Meaning, Retry-After and Fixes
- 403 Forbidden: Meaning, Causes and How to Fix It
- 401 Unauthorized: What It Means and How to Fix It
- 500 Internal Server Error: Causes and How to Fix It
- 503 Service Unavailable: Causes and Fixes
- 400 Bad Request: Causes and Fixes (Including Cookie Too Large)
- 301 Moved Permanently: Meaning, SEO and Examples
- 302 Found: Temporary Redirects Explained
- 408 Request Timeout: Causes and How to Fix It