4xx Client errors
Last updated Jul 25, 2023

404 - Not Found

Get your free
API key now
4.8 from 1,863 votes
See why the best developers build on Abstract
START FOR FREE
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required

The HTTP Status Code 404 means that the requested resource could not be found by the server but that it may be available in the future.

What is HTTP Status Code 404?


HTTP Status Codes in General


HTTP status codes are a fundamental part of the HTTP protocol, or Hypertext Transfer Protocol, the foundation of data communication on the world wide web. The 404 status code falls under client error responses, and it's one you might have encountered before.


Intro to HTTP Status Code 404


HTTP status code 404, also known as 'Not Found', is one of the most common HTTP status codes. If you've ever clicked on a web page only to be greeted with a message saying "404: Page Not Found", then you've encountered this status code. What does this status code mean? In essence, it tells us that the requested URL could not be found on the server.


A 404 error typically occurs when the server can't find the requested resource - the web page or other resource simply doesn't exist. This can happen due to several reasons. You may have entered an incorrect URL, the page might have been moved or deleted, or there might be broken links on the website.


Understanding Soft 404s


An interesting twist on the traditional 404 error is the 'soft 404'. Soft 404s occur when a web page is missing, but the server returns a 200 OK status code rather than the appropriate 404. This can confuse search engines and potentially waste link equity, as search engines may continue to attempt to index a page that doesn't exist.



When and How is HTTP Status Code 404 used?


Common Causes of 404 Errors


A 404 HTTP error can occur due to several reasons. These include a mistyped URL, an outdated or broken link, or a page that was moved without a permanent redirect being set up. Additionally, server errors can lead to a 404 error page being displayed, even if the page exists. This is why it's crucial to check the server configuration and .htaccess file regularly.


In terms of HTTP requests, the request method (GET, POST, etc.) doesn't affect the possibility of receiving a 404 status. Whether you're requesting a web page or attempting to post data to a web app, a 404 error indicates that the requested URL couldn't be found.


Responding to 404 Errors


When a web server returns a 404 status code, it should also send an error page to the user's web browser, such as Google Chrome, Mozilla Firefox, or Microsoft Edge. This error page can be customized to provide a better user experience than the standard "404 Not Found" message.


One good practice is to provide a link back to the home page or include a search box so the user can find the information they're looking for. Custom 404 error pages can also reflect your brand, offer an explanation of why the page might be missing, or even include some humor to lighten the mood.


404s and Search Engines


From a search engine optimization perspective, too many 404 errors can negatively impact a site's ranking. Google Search Console, for example, provides reports on 404 errors so webmasters can fix these issues. Broken links leading to 404 pages can be seen as a sign of a low-quality site by search engines, which is why it's essential to fix these errors as soon as possible.



Example Usage of HTTP Status Code 404


Non-Technical Example


Imagine you're trying to find a specific book in a library's online catalog. You type in the title and click the link to view the book's details, but instead, you're taken to a page with a message saying, "We're sorry, but the book you're looking for cannot be found." This is a real-world, non-technical example of a 404 error. The library's server received your request but couldn't find the book in its database, so it returned a 404 status code.


Technical Example


Now, let's look at a more technical example, one that involves some code.


Let's say you're building a website with a page dedicated to a blog post. This page is dynamic, meaning it changes based on the blog post's unique ID that's passed in the URL (e.g., `www.yoursite.com/blog/123`). The server uses this ID to fetch the corresponding blog post from the database.




from flask import Flask, abort, render_template

app = Flask(__name__)

@app.route('/blog/')
def blog_post(id):
    post = database.get_post(id)
    if post is None:
        abort(404)
    return render_template('post.html', post=post)


In the above Python code using the Flask web framework, when a request comes in for a specific blog post, the server first tries to fetch the post from the database using the ID. If no post with that ID exists, the server returns a 404 error using the `abort(404)` function, indicating that the requested resource could not be found on the server.



What is the History of HTTP Status Code 404?


HTTP status code 404 has been a staple of the web since its early days. The first documented case of a 404 error appearing on a web page was in 1993 when a user tried to access a page about the Mosaic web browser on the NCSA website. The page had been moved to a different location, but the link had not been updated. The user reported the error to the NCSA team, who fixed the link and added a humorous message to their 404 page: "We're sorry, but the document you requested is not here. Maybe you should try someplace else". This anecdote shows that the 404 status code has been facilitating better web navigation for nearly three decades.



How Does HTTP Status Code 404 Relate to Other Status Codes?


The 404 status code is part of a larger group of HTTP status codes that each serves a unique purpose in conveying the outcome of an HTTP request. HTTP status codes are grouped into five classes, each identified by the first digit of the code:


1. 1xx (Informational): The request was received, and the process is continuing.
2. 2xx (Successful): The request was successfully received, understood, and accepted.
3. 3xx (Redirection): Further action must be taken to complete the request.
4. 4xx (Client Error): The request contains bad syntax or cannot be fulfilled.
5. 5xx (Server Error): The server failed to fulfill a valid request.


The 404 status code falls under the 4xx class, indicating a client error. It specifies that the client's request was syntactically correct but the server couldn't find the requested resource.



Other Intriguing Aspects of HTTP Status Code 404


The Role of HTTP Status Code 404 in SEO


One particularly intriguing aspect of HTTP status code 404 involves its role in Search Engine Optimization (SEO). When search engines like Google crawl your website, they keep track of any 404 errors they encounter. Too many 404 errors can negatively impact your site's SEO, as search engines might interpret this as a sign of a poorly maintained site. However, handling 404 errors appropriately can minimize this impact. For instance, setting up a custom 404 error page can help keep users engaged even when they stumble upon a missing page.


HTTP Status Code 404 and Soft 404s


A related concept is that of "soft 404s". Unlike a typical 404 error, a soft 404 occurs when a web page that doesn't exist appears to the user as if it does, often displaying a 200 OK status code. This can confuse search engines and lead to problems with how your website is indexed. Google Search Console is a valuable tool that can help you identify and rectify soft 404s on your site.


Creative Use of 404 Error Pages


Lastly, while HTTP status code 404 is often associated with frustration for users, it also offers a unique opportunity for creativity. Many websites turn their 404 error pages into works of art or interactive games, providing entertainment to users while also guiding them back to the home page. This not only enhances user experience but also helps retain potential link equity lost from the broken link.


While HTTP status code 404 is essentially a simple tool for indicating missing web pages, it has far-reaching implications for user experience, SEO, and even the opportunity for creative expression. Understanding its intricacies can help web developers make the most out of these unavoidable occurrences.

Get your free
API
key now
4.8 from 1,863 votes
See why the best developers build on Abstract
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required