HTTP 404 Not Found

HTTP 404 Not Found: causes, fixes for visitors and site owners, nginx and Express snippets, and how it differs from 410.

loading HTTP 404 Not Found
About this tool

404 Not Found: what it means

The server was reached and understood the request, but there is nothing at that address. A 404 is a working answer, not a dead server: the host is up, the path is what is missing. The standard also lets a server use it to hide a resource it prefers not to admit exists.

The code belongs to the 4xx class and its official name is "Not Found". The page opens the status code list on 404, so you can compare it with its neighbours.

What the response looks like

HTTP/1.1 404 Not Found
Content-Type: text/html; charset=utf-8
Content-Length: 146

Common causes

  • A typo or a truncated link, often a trailing character that came with the URL when it was pasted.
  • A page that was moved or deleted without a redirect from the old address.
  • Upper and lower case: /About and /about are different files on Linux servers.
  • A file the deploy forgot to upload, such as an image, a script or a build asset with a new hash in its name.
  • A single-page app opened on a deep route (/orders/42) when the server has no fallback to index.html.

How to fix it

If you are a visitor

  • Check the address for typos and remove anything after the last slash you are unsure about.
  • Go to the site's home page or search and look for the page by its title.
  • For an old link, try the copy in the Internet Archive's Wayback Machine.

If you run the site or the API

  • Read the access log to see which URLs return 404 and who links to them (the Referer column).
  • Add a 301 redirect for every page that moved; use 410 Gone for content removed on purpose.
  • In a single-page app, send unknown paths to index.html and let the router show its own not-found view.
  • Make the custom error page answer with status 404, not 200: a "not found" page served with 200 is a soft 404.

Snippets to copy

nginx: a fallback for a single-page app and a custom 404 page

location / {
    try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;

Express: a real 404 for unknown API routes

app.use((req, res) => {
  res.status(404).json({ error: 'not_found', path: req.path });
});

Codes it is confused with

CodeDifference
410 GoneThe resource existed and was removed on purpose; search engines drop it faster.
403 ForbiddenThe resource exists but you may not see it.
400 Bad RequestThe request itself is malformed, whatever the address.
301 Moved PermanentlyThe resource moved and the server knows where to.

Caching, retries and search engines

Search engines drop a URL that keeps answering 404 from the index after a while, so the damage is the lost links, not a penalty on the rest of the site. Do not redirect every 404 to the home page: Google treats that as a soft 404 and ignores it.

Look up other status codes

  1. Open the list and type a number (404) or a word (timeout) in the search box.
  2. Read the description of the code and copy "404 Not Found" with the button on its card.
  3. Use the # button to copy a link straight to that code.

Frequently asked questions

Does a 404 error hurt my SEO?

A few 404s are normal and do not lower the ranking of the rest of the site. It costs you when a page with good links goes 404: those links stop passing value. Redirect those with a 301.

What is the difference between 404 and 410?

404 says "not found, maybe later"; 410 says "gone for good". Use 410 for content you removed on purpose and will not bring back.

Why does my app show 404 only when I refresh the page?

Inside the app the router handles the route; on refresh the browser asks the server for that path, and the server has no such file. Send unknown paths to index.html.

Report a problem