DEV Community

Cover image for Why the 404 error ?
Clément Gaudinière
Clément Gaudinière

Posted on

Why the 404 error ?

Hello everyone, today we're going to look at HTTP errors, you know like when you get a page not found with the 404 error. In reality there are almost a hundred different error codes. Don't worry, it's difficult to know them all by heart, but there are techniques to find out roughly where the error comes from. You are ready, so let's go !

Why did you invent these numbers ?

But then why did we invent these error numbers? The answer is actually quite simple, when a user requests a web page through his browser, the browser will send a request to the server under the world famous HTTP protocol. The server will also respond in HTTP format, and if all goes well will send the requested resource (in our case the web page). But everything gets complicated when there is an error. Knowing that there is an error is good, but knowing where is even better. This is why error numbers were quickly assigned to each different type of error. This is much more practical and saves time for many developers. For example, errors starting with 5 are problems at the server level.

The five categories of error

To simplify the whole thing, and to put some order in all these errors, categories have been created. There are three different categories:
1 - Informations
2 - Success
3 - Redirects
4 - Web client errors
5 - Server errors

The five categories of error

So if an error number starts with 4, we know directly that the problem comes from the web client.

Why 404 error ?

But why 404 errors? If you have been following this, you will notice that the first number is a 4 and that the error comes directly from the web client and not from the server. Indeed, the 404 error means that the resource is not found, the server has searched for it on its side but has not found it, so the error comes from the web client which has not provided the right url.

404 error

Going further with error 418

The HTTP error 418 has nothing to do with the other errors. Indeed its meaning is "I'm a teapot". It is actually a joke since it first appeared in the famous RFC 2324 on April 1, 1998. The explanations given by the developers are: " There is coffee all over the world. Increasingly, in a world in which computing is ubiquitous, the computists want to make coffee. Coffee brewing is an art, but the distributed intelligence of the web- connected world transcends art. Thus, there is a strong, dark, rich requirement for a protocol designed expressly for the brewing of coffee. Coffee is brewed using coffee pots. Networked coffee pots require a control protocol if they are to be controlled".
In other words, the famous Hyper Text Coffee Pot Control Protocol, or HTCPCP, is intended to send an error back to all those who would like to control a coffee pot remotely, telling them that they have mistakenly addressed themselves to ... a teapot 😂.
This April 1st "joke" had its heyday at the time and is still featured on a number of official links in which its error code has been preserved.
There are still people asking questions about this 418 error, even today!

Google teapot

Specific errors

For those who wish to find a specific error, you can refer to these different tables classified by categories.
Some codes are not yet in use, but are intended for future use. Other codes do not result in any specific display to the user, but are implied (e.g. codes 200 or 304, which are never seen by the client as they concern the majority of successful requests).

All major HTTP errors are represented in these different tables, of the different error types:

Codes beginning with 1 (Informations):

Code Message Meaning
100 Continue Waiting for the application to be processed.
101 Switching Protocols Acceptance of the change of protocol.
102 Processing Processing in progress (prevents the customer from exceeding the waiting time limit).
103 Early Hints While waiting for the final response, the server returns links that the client can start downloading.

Codes beginning with 2 (Success):

Code Message Meaning
200 OK Request successfully processed. The response will depend on the query method used.
201 Created Request successfully processed and document created.
202 Accepted Request processed, but no guarantee of result.
203 Non-Authoritative Information Information returned, but generated by an uncertified source.
204 No Content Request successfully processed but no information to return.
205 Reset Content Request successfully processed, current page can be deleted.
206 Partial Content Only part of the resource has been transmitted.
207 Multi-Status Multiple answers.(WebDav)
208 Already Reported The document was previously sent in this collection.(WebDav)
210 Content Different The copy of the resource on the client side differs from that on the server (content or properties).(WebDav)
226 IM Used The server has completed the request for the resource, and the response is a representation of the result of one or more instance manipulations applied to the current instance.

Codes beginning with 3 (Redirects):

Code Message Meaning
300 Multiple Choices The requested URI refers to several resources.
301 Moved Permanently Permanently moved document.
302 Found Document moved temporarily.
303 See Other The answer to this request lies elsewhere.
304 Not Modified Document not modified since the last request.
305 Use Proxy (since HTTP/1.1) The request must be re-addressed to the proxy.
306 Switch Proxy Code used by an older version of RFC 26167, now reserved. It meant "The following requests must use the specified proxy ".
307 Temporary Redirect The request must be temporarily redirected to the specified URI.
308 Permanent Redirect The request must be permanently redirected to the specified URI.
310 Too many Redirects The request has to be redirected too many times, or falls victim to a redirection loop.

Codes beginning with 4 (Web client errors):

Code Message Meaning
400 Bad Request The syntax of the query is wrong.
401 Unauthorized Authentication is required to access the resource.
402 Payment Required Payment required to access the resource.
403 Forbidden The server has understood the request, but refuses to execute it. Unlike the 401 error, authenticating will not make any difference. On servers where authentication is required, this usually means that authentication has been accepted but the access rights do not allow the client to access the resource.
404 Not Found Resource not found.
405 Method Not Allowed Unauthorised query method.
406 Not Acceptable The requested resource is not available in a format that would respect the "Accept" headers of the request.
407 Proxy Authentication Required Access to the resource allowed by identification with the proxy.
408 Request Time-out The amount of time a request from the client has been waiting on the server side. According to the HTTP specification: "The client did not produce a request within the time the server was willing to wait. The client MAY repeat the request without modification at any later time ".
409 Conflict The request cannot be processed at this time.
410 Gone The resource is no longer available and no redirection address is known.
411 Length Required The length of the request was not specified.
412 Precondition Failed Preconditions sent by the request not checked.
413 Request Entity Too Large Treatment abandoned due to too high a demand.
414 Request-URI Too Long URI too long.
415 Unsupported Media Type Unsupported query format for a given method and resource.
416 Requested range unsatisfiable Incorrect "range" query header fields.
417 Expectation failed Expected and defined behaviour in the header of the unsatisfactory request.
418 I’m a teapot "I am a teapot": This code is defined in RFC 232410 dated 1 April 1998, Hyper Text Coffee Pot Control Protocol. It is a webmaster's joke, intended to send an error back to anyone who wants to remotely control a coffee pot, telling them that they have mistakenly addressed a teapot :)
421 Bad mapping / Misdirected Request The request has been sent to a server that is not capable of producing a response (for example, because a connection has been reused).
422 Unprocessable entity The entity provided with the request is incomprehensible or incomplete.(WebDAV)
423 Locked The operation cannot take place because the resource is locked.(WebDAV)
424 Method failure A method in the transaction has failed.(WebDAV)
425 Too Early The server cannot process the request as it may be replayed.
426 Upgrade Required The client should change the protocol, for example to TLS/1.0.
428 Precondition Required The request must be conditional.
429 Too Many Requests The customer has made too many requests within a given time frame.
431 Request Header Fields Too Large The HTTP headers sent exceed the maximum size allowed by the server.
449 Retry With Code defined by Microsoft. The request should be returned after performing an action.
450 Blocked by Windows Parental Controls Code set by Microsoft. This error occurs when Windows Parental Controls are enabled and block access to the page.
451 Unavailable For Legal Reasons This error code indicates that the requested resource is inaccessible for legal reasons.
456 Unrecoverable Error Unrecoverable error.(WebDAV)

Codes beginning with 5 (Server errors):

Code Message Meaning
500 Internal Server Error Internal server error.
501 Not Implemented Claimed functionality not supported by the server.
502 Bad Gateway ou Proxy Error By acting as a proxy or gateway server, the server received an invalid response from the remote server.
503 Service Unavailable Service temporarily unavailable or under maintenance.
504 Gateway Time-out Time taken to wait for a response from a server to an intermediate server.
505 HTTP Version not supported HTTP version not supported by the server.
506 Variant Also Negotiates Negotiation error.
507 Insufficient storage Insufficient space to edit properties or build the collection.(WebDAV)
508 Loop detected Loop in a resource linkage.(WebDAV)
509 Bandwidth Limit Exceeded Used by many servers to indicate a quota overrun.
510 Not extended The request does not respect the extended HTTP resource access policy.
511 Network authentication required The client must authenticate to access the network. Used by captive portals to redirect clients to the authentication page.

I hope you have enjoyed this article. If you have any questions, feel free to ask me in the comments. 👍

Top comments (2)

Collapse
 
pandademic profile image
Pandademic

Thank you !

Collapse
 
clementgaudiniere profile image
Clément Gaudinière

Glad have could help you !