DEV Community

Dodo Mukunzi
Dodo Mukunzi

Posted on

Top 10 Commonly Used HTTP Status Codes

HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped into five classes: informational responses, successful responses, redirects, client errors, and server errors.

Here are the 10 commonly used and useful HTTP status codes:

1xx: Informational

None in this class.

2xx: Success

200 OK

It is the general status code. Most common code used to indicate success.
The request has succeeded. The meaning of success varies depending on the HTTP method:
GET: The resource has been fetched and is transmitted in the message body.
HEAD: The entity headers are in the message body.
PUT or POST: The resource describing the result of the action is transmitted in the message body.
TRACE: The message body contains the request message as received by the server

201 Created

Successful creation occurred (via either POST or PUT). Set the Location header to contain a link to the newly-created resource (on POST). Response body content may or may not be present.

204 No Content

Status when wrapped responses are not used and nothing is in the body (e.g. DELETE).

3xx: Redirection

304 Not Modified

This is used for caching purposes. It tells the client that the response has not been modified, so the client can continue to use the same cached version of the response.

4xx: Client Error

400 Bad Request

General error when fulfilling the request would cause an invalid state. Domain validation errors, missing data, etc. are some examples.

401 Unauthorized

The error code response for missing or invalid authentication token.

403 Forbidden

The error code for a user not authorized to perform the operation or the resource is unavailable for some reason (e.g. time constraints, etc.).

404 Not Found

Used when the requested resource is not found, whether it doesn't exist or if there was a 401 or 403 that, for security reasons, the service wants to mask.

409 Conflicts

Whenever a resource conflict would be caused by fulfilling the request. Duplicate entries and deleting root objects when cascade-delete is not supported are a couple of examples.

5xx: Server Error

500 Internal Server Error

The general catch-all error when the server-side throws an exception.

Top comments (0)