Commonly used HTTP codes and their meanings
What you will learn
By going through this article, you will learn about some common HTTP status codes, what they mean and when they are typically used.
What are HTTP Status Codes?
Simply put, a HTTP status code is a three-digit number used to indicate whether a specific HTTP request was successfully completed or not. There are five groups of HTTP status codes:
Informational responses (100 - 199)
Successful responses (200 - 299)
Redirects (300 - 399)
Client errors (400 - 499)
Server errors (500 - 599)
A great way to think of status codes is: any status code starting with "1" is an informational response, anyone starting with "2" is a successful response, starting with "3" is a redirect, starting with "4" is a client error, and starting with "5" is a server error.
Commonly used HTTP status codes
This status code is the one you would see most frequently if you're working on the backend of an app. It means that the request made to the server has successfully been sent.
This is used when a new resource or object has been successfully created. For example when you create a new product in an E-commerce app.
404 Not found
When you try to open a web page that does not exist, this is the status code you would see. It simply means that the server did not find anything matching the request URI. Most times this code is used when the server does not wish to show exactly why the request was refused, or when there's no other response applicable.
When a server requires authentication before it fulfills your request, and no authentication has been provided, it will return this status code. In this case, all you need to do is provide the proper authentication to get a 200 OK response.
This code usually shows up if the server understands your request but has refused to fulfill it. This is different from a 401 code because not even authentication can help in this case, and it is advisable to not repeat the request.
500 Internal server error
This status code will show up if the server encountered an unexpected condition that prevented it from fulfilling the request. It is a generic error code and it often does not have a specific message.
503 Service unavailable
This status code means that the server is experiencing a temporary overload or there is some maintenance going on. In most cases a "retry after x minutes" will be displayed to let you know when to retry the request.
504 Gateway timeout
When the server is acting as a gateway or proxy, and does not receive a timely response from the upstream server specified by the URI or from an auxiliary server, it returns this status code.
502 Bad Gateway
In this case, the server while acting as a gateway or proxy, receives an invalid response from the upstream server.
There you have it, some commonly used HTTP status codes and what they do. The full list of standard HTTP status codes can be found on MDN Web Docs, and this handy resource from RestApi Tutorial's website does a good job of arranging it in a way that is much easier to understand.
Tell me in the comments which HTTP status codes you have come across and how you used it. Thank you for reading this!