404 Not Found - HTTP | MDN

MDN Web Docs 2 min read
View original
Crawl details
  • Current
Summary (TL;DR)
HTTP 404 Not Found is a client error status code that means the server cannot find the requested resource. It appears when a URL doesn't match any existing page, like a deleted blog post. The response includes headers like Cache-Control and Content-Type, and an HTML error page. Apache servers can use a .htaccess file with ErrorDocument 404 /notfound.html to show a custom error page. The article advises using custom 404 pages in moderation, making them humorous but not confusing. It links to the HTTP Semantics specification and mentions related codes like 410 Gone. It also references a KonMari 404 page as an example.

Status

http

404 Not Found

Examples

Page not found

Fetching a non-existent page may look like the following request:

http

GET /my-deleted-blog-post HTTP/1.1
Host: example.com

The server returns a response similar to this:

http

HTTP/1.1 404 Not Found
Age: 249970
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Fri, 28 Jun 2024 11:40:58 GMT
Expires: Fri, 05 Jul 2024 11:40:58 GMT
Last-Modified: Tue, 25 Jun 2024 14:14:48 GMT
Server: ECAcc (nyd/D13E)
Vary: Accept-Encoding
X-Cache: 404-HIT
Content-Length: 1256

<!doctype html>
<head>
    <title>404 not found</title>
    ...

Custom error page in Apache

For the Apache server, you can specify a path to a custom 404 page in a .htaccess file. The example below uses notfound.html as a page to show visitors on 404s, although a common approach is to name the file 404.html or 404.php (depending on the server-side technology) at the top-level of the server:

apacheconf

ErrorDocument 404 /notfound.html

Note: Custom 404 page design is a good thing in moderation. Feel free to make your 404 page humorous and human, but don't confuse your visitors as to why they are seeing something unexpected.

For an example of a custom 404 page, see the KonMari 404 page.

Specifications

Specification
HTTP Semantics
# status.404

See also

Help improve MDN

Was this page helpful to you?

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.