12 Common HTTP Status Codes and Their Meanings

Joy MukherjeeJoy Mukherjee
3 min read

HTTP (Hypertext Transfer Protocol) status codes are three-digit numbers returned by web servers to indicate the result of a client's request made to the server. These codes provide essential information about the success, failure, or redirection of the request. Understanding these status codes is crucial for web developers, sysadmins, and anyone involved in web technologies. In this article, we will explore 12 common HTTP status codes and their meanings.

1. 200 OK

The 200 OK status code is the most straightforward. It indicates that the request was successful, and the server has returned the requested resource. This is the status code you want to see for most of your HTTP requests.

2. 201 Created

When a new resource is successfully created as a result of a POST request (typically in a RESTful API), the server responds with a 201 Created status code. It also includes a Location header pointing to the newly created resource.

3. 204 No Content

The 204 No Content status code indicates that the request was successful, but the server is not sending back any content in the response body. It's often used for successful DELETE requests.

4. 400 Bad Request

A 400 Bad Request status code implies that the server cannot understand or process the client's request due to malformed syntax, missing parameters, or other client-side errors. The response often includes details about what went wrong.

5. 401 Unauthorized

The 401 Unauthorized status code indicates that the request requires authentication, and the client has not provided valid credentials or authentication tokens. The client may need to log in or provide proper authorization.

6. 403 Forbidden

Unlike 401, a 403 Forbidden status code means that the server has understood the request but refuses to fulfill it. This typically happens when the client doesn't have the necessary permissions to access the requested resource.

7. 404 Not Found

The 404 Not Found status code is perhaps the most recognized. It indicates that the requested resource does not exist on the server. This can occur when a URL is misspelled, a resource is deleted, or the server's routing is incorrect.

8. 500 Internal Server Error

The 500 Internal Server Error status code is a generic error message indicating that an unexpected condition has occurred on the server, and it doesn't know exactly what went wrong. This error should be logged and investigated on the server side.

9. 502 Bad Gateway

A 502 Bad Gateway status code indicates that a server acting as a gateway or proxy received an invalid response from an upstream server. This often occurs when a web server behind a reverse proxy or a load balancer is not functioning correctly.

10. 503 Service Unavailable

When a server is temporarily unable to handle the request, it responds with a 503 Service Unavailable status code. This can occur due to server maintenance, overloading, or other temporary issues.

11. 301 Moved Permanently

A 301 Moved Permanently status code tells the client that the requested resource has been permanently moved to a different URL. The client should update its bookmarks or links to use the new URL provided in the Location header.

12. 304 Not Modified

The 304 Not Modified status code is used to reduce bandwidth usage. When a client makes a conditional GET request (e.g., with an If-Modified-Since header) and the resource has not changed since the specified date, the server responds with 304. This indicates that the client's cached version is still valid.

These are just a few of the many HTTP status codes that exist. HTTP is a rich protocol with codes for various scenarios, from success to error handling and redirection. Understanding these codes and their meanings is essential for web developers and administrators to diagnose and troubleshoot issues effectively.

0
Subscribe to my newsletter

Read articles from Joy Mukherjee directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Joy Mukherjee
Joy Mukherjee

Web developer and bug bounty hunter. Passionate about building and securing web applications. Writing about web development, bug bounty hunting, and other related topics.