4xx Client Errors

HTTP 404 Not Found

The server cannot find the requested resource. The most common error on the web.

When is 404 used?

  • Broken links
  • Non-existent API endpoints
  • Deleted resources

How to handle a 404 response

Inspect the request — URL, method, headers, credentials, and body. Retrying the same request unchanged will usually fail again; 429 is the exception, where you should wait for the Retry-After period.

Check the status code a URL returns from the command line:

curl -s -o /dev/null -w "%{http_code}\n" https://example.com

How to return 404 from your server

Node.js (Express)

res.status(404).json({ message: 'Not Found' });

Python (Flask)

return {"message": "Not Found"}, 404

Go (net/http)

w.WriteHeader(404)

Frequently Asked Questions

What does HTTP 404 mean?

404 Not Found: The server cannot find the requested resource. The most common error on the web.

Is 404 an error?

Yes. 404 is in the 4xx Client Errors class. Client errors: the request is malformed, unauthorized, or targets something that does not exist.