Working on the web means coming into contact with HTTP responses. Whether you spend your time primarily on the client or on the server, you're likely familiar with the popular ones like 200, 404, and 500. While memorizing all the codes using cat memes as a mnemonic can be helpful, let's dive deeper into what some of the most common codes mean.
What is an HTTP status code?
HTTP response status codes are a set of standardized and agreed upon numbers that identify information about an http response.
Status codes are 3 digits and broken down into 5 categories, each organized by the first digit of the number. You'll see these abbreviated as the first number, followed by two "x" characters. For example, "4xx".
- 1xx: Informational provides information about a request in progress.
- 2xx: Successful indicates that the request was received and accepted.
- 3xx: Redirection indicates that the request has to be redirected.
- 4xx: Client Error indicates that an error has occurred on the client.
- 5xx: Server Error indicates that an error has occurred on the server.
If you're consuming an API, it is usually safe to assume that it conforms to these standardized codes. If you are the one creating an API, make sure to match your responses with the appropriate code.