404 Not Found

HTTP response status code 404 Not Found is a common and general client error that is returned by the server to indicate that a resource can not be found at the specified address.

The response is cacheable by default. If the default behavior needs to be overridden then the response must include the appropriate HTTP caching headers.

Usage

When the 404 Not Found error message is received, it does not specify whether the resource is permanently unavailable, temporarily unavailable, never existed, or otherwise. It most often happens with mistyped URLs and is often seen by developers that are working with a set of resources that is a work in progress.

Links to addresses that result in the 404 Not Found are commonly known as dead links, or broken links. It has also been used when a server is unwilling to acknowledge that the resource exists.

If a server has knowledge that the resource did once exist at the specified address, but has been permanently removed, then a 410 Gone status will be more informative.

Because this type of error is so commonly seen by end-users, many servers use a custom error page that is descriptive and relevant for their site.

Note

Search engines like Google will not index a URL with 404 Not Found response status, and consequently, URLs that have been indexed in the past but are now returning this HTTP status code will be removed from the search results.

Example

In the example, the client requests a resource and the server responds with the 404 Not Found status message because the resource does not exist, and has never existed as far as the server is aware.

Request

GET /documents/secret-formula.pdf HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 404 Not Found
Content-Type: text/html
Content-Length: 216

<html>
  <head>
    <title>Resource Not Found</title>
  </head>
  <body>
    <p>The resource you requested has not been found at the specified address. Please check the spelling of the address.</p>
  </body>
</html>

Code references

.NET

HttpStatusCode.NotFound

Rust

http::StatusCode::NOT_FOUND

Rails

:not_found

Go

http.StatusNotFound

Symfony

Response::HTTP_NOT_FOUND

Python3.5+

http.HTTPStatus.NOT_FOUND

Java

java.net.HttpURLConnection.HTTP_NOT_FOUND

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_NOT_FOUND

Angular

@angular/common/http/HttpStatusCode.NotFound

Takeaway

The 404 Not Found HTTP status code is a client error used to indicate that a resource was not found at the specified address. It is most likely the result of a dead link or a misspelled address.

See also

Last updated: August 2, 2023