Understanding HTTP Status Codes#

HTTP response status codes provide crucial information about the outcome of an HTTP request. They are categorized into five classes: Informational (100-199), Successful (200-299), Redirection (300-399), Client Error (400-499), and Server Error (500-599). Each class indicates a different type of response from the server.

  • Informational responses (100-199) indicate interim actions.
  • Successful responses (200-299) confirm that the request was processed successfully.
  • Redirection messages (300-399) prompt the client to take additional action to complete the request.
  • Client error responses (400-499) signal issues originating from the client side.
  • Server error responses (500-599) indicate problems on the server side.

References: [1]

Common Successful Responses#

Successful responses (200-299) are essential for confirming that your API requests are being handled correctly. The most common successful response is 200 OK, which means the request was successful and the server is returning the requested data.

  • 200 OK: The request succeeded.
  • 201 Created: A new resource was created as a result of the request.
  • 204 No Content: The request was successful, but there is no content to return.

References: [1]

Handling Client Errors#

Client error responses (400-499) are critical for identifying issues with the request itself. These errors often require adjustments to the request parameters or headers to resolve.

  • 400 Bad Request: The server could not understand the request due to invalid syntax.
  • 401 Unauthorized: Authentication is required to access the resource.
  • 403 Forbidden: The client does not have permission to access the resource.
  • 404 Not Found: The requested resource could not be found on the server.

References: [1]

Addressing Server Errors#

Server error responses (500-599) indicate that something went wrong on the server side. These errors are usually temporary and can be resolved by the server administrators.

  • 500 Internal Server Error: The server encountered an unexpected condition that prevented it from fulfilling the request.
  • 502 Bad Gateway: The server received an invalid response from an upstream server.
  • 503 Service Unavailable: The server is currently unable to handle the request due to temporary overloading or maintenance.

References: [1]

Using the Retry-After Header#

The Retry-After header provides guidance on when to retry a request after receiving certain status codes, particularly 503 Service Unavailable and 429 Too Many Requests. This header can help manage retries efficiently.

  • In a 503 response, Retry-After indicates how long the service is expected to be unavailable.
  • In a 429 response, Retry-After suggests the delay before making a new request.
http
Retry-After: 120
Retry-After: Wed, 21 Oct 2015 07:28:00 GMT

References: [2]

Practical Example: Debugging a 404 Error#

Suppose you are making a GET request to fetch a user profile and receive a 404 Not Found error. To debug this issue, follow these steps:

  • Verify the URL: Ensure that the URL is correct and matches the API documentation.
  • Check the request method: Confirm that you are using the correct HTTP method (GET in this case).
  • Inspect the request headers: Look for any missing or incorrect headers that might be causing the error.
  • Review the server logs: Check the server logs for any additional information about why the resource was not found.
http
GET /api/users/123 HTTP/1.1
Host: example.com

Sources & methodology

This article was prepared from the official pages below and checked automatically. Verify examples against current documentation and your project before using them.

  1. HTTP response status codes - HTTP | MDNSource retrieved: 2026-11-22
  2. Retry-After header - HTTP | MDNSource retrieved: 2026-11-22

Turn the idea into reviewable work.

Bring your models, editor, terminal and browser together in Devura.

Get Devura