Skip to content
4xx · client errorSent by App | Proxy | CDN

404Not Found

The server has nothing at this address, or is not willing to say that it does.

How you get a 404

The address is valid and the app handles it. It asks the database for record 42 and gets nothing back. With no record to show, the app sends 404.

Who sends itApp · Proxy · CDN

  1. Browser
  2. CDN
  3. Proxy
  4. App
  5. DB

Typically the app, when it looks for a record and finds none. The proxy or CDN sends it when no route or file matches the address, and then the app is never asked.

In short

What a 404 Not Found means

A 404 Not Found means the server looked for something at this address and has nothing to return, or prefers not to reveal that it does. It says nothing about whether the thing ever existed or will exist later. The first thing to work out is who looked. When the application sends it, the route matched and a lookup came back empty: a deleted record, an ID from another environment. When the proxy or CDN sends it, no route or file matched the address at all, which points to a typo, a missing deploy or a wrong path prefix, and the application has no record of the request. A 404 is cacheable by default, so a CDN can keep answering 404 for a short while after the page has been created.

Common causes of a 404

  1. 1A typo, wrong case or missing path prefix in the URL.

    How to check: Compare the address with a known good one, character by character, including the trailing slash.

  2. 2The record was deleted, or the ID belongs to another environment.

    How to check: Look the ID up directly in the database you are actually talking to.

    SELECT id FROM items WHERE id = 42;
  3. 3The route or file is missing from this deploy, or the proxy looks in the wrong folder.

    How to check: nginx logs the exact file path it tried.

    open() "/var/www/html/app.js" failed (2: No such file or directory)
  4. 4The record was just created and the read went to a replica that has not caught up.

    How to check: The same request succeeds a moment later. Read your own writes from the primary.

  5. 5The server hides something you may not see by answering 404 instead of 403.

    How to check: Try with an account that has access.

Retry or not?

Retry only after fixing the request

Usually the address is wrong and retrying will not make it right. The exception is a record created a moment ago, where one retry after a short wait is reasonable.

Headers that matter

Cache-Control
A 404 may be cached. A CDN that stored it keeps answering 404 until the entry expires, even after the page exists.
Server
Shows whether the app, the proxy or the CDN wrote the error page, which tells you where the lookup failed.

In the real world

RFC vs real deployments

RFC 9110 says a 404 does not reveal whether the absence is temporary or permanent, and offers 410 Gone for the permanent case; in practice 410 is rare. The RFC also allows 404 as a way to hide resources. The opposite mistake is the “soft 404”: a friendly not-found page served with status 200, which caches and search engines then treat as real content.

Seen in a real outage

“Not found” is not always true. In 2019 Monzo added nodes to a database cluster, and for a while customers were told their data did not exist when requests reached nodes that did not hold it yet.

Your turn

Which code is it?

After a deploy, /static/app.9f3c.js returns a 404 page from nginx on one of three servers, and works on the other two. The app log is empty for these requests. What is the likely cause?

404 questions

Who sends a 404 Not Found?
Typically the application, when a lookup finds no record. A proxy or CDN sends it when no route or file matches the address, and then the application is not involved.
Does a 404 mean the page was deleted?
Not necessarily. It only means nothing is there now. The address may be mistyped, the page may never have existed, or the server may be hiding it.
Is a 404 cached?
It can be. A 404 is cacheable by default, so a CDN may repeat it for a short time after the page has been created.

Sources: RFC 9110: 404 Not Found (section 15.5.5) ↗ · Report a problem

Diagrams are our own simulations. All wording is original and paraphrases the linked sources.

Practise this in the DNS / HTTP track

Two-minute animated lessons, then boss fights from real outages. Free, no account needed.

Start the track