HTTP Status Codes: Complete Reference Guide

HTTP status codes are three-digit numbers returned by a web server in response to a client's request. They tell you whether a request succeeded, was redirected, encountered an error, or something else entirely. Understanding these codes is essential for web development, API design, debugging, and SEO.

This complete reference covers every status code category with practical explanations. When building APIs, use our URL Encoder to properly encode query parameters and URLs.

Status Code Categories

RangeCategoryMeaning
1xxInformationalRequest received, processing continues
2xxSuccessRequest successfully received and processed
3xxRedirectionFurther action needed to complete request
4xxClient ErrorRequest contains bad syntax or cannot be fulfilled
5xxServer ErrorServer failed to fulfill a valid request

1xx Informational Responses

2xx Success Codes

3xx Redirection Codes

4xx Client Error Codes

5xx Server Error Codes

Best Practices for API Status Codes

  1. Be specific: Use 201 for creation, 204 for no content, not 200 for everything.
  2. Use 4xx for client mistakes: 400 for bad input, 422 for validation errors, 409 for conflicts.
  3. Reserve 5xx for genuine server failures: Don't return 500 for invalid input.
  4. Include helpful error bodies: Return JSON with error codes, messages, and field-level details.
  5. Set proper headers: Retry-After for 429/503, Location for 201, Allow for 405.

Properly encode your API URLs and query parameters with our URL Encoder to avoid 400 errors from malformed requests.

Frequently Asked Questions

What is the difference between 401 and 403?

401 Unauthorized means the client hasn't provided valid authentication credentials โ€” they need to log in or provide an API key. 403 Forbidden means the client is authenticated but doesn't have permission to access the resource. Re-authenticating won't help with a 403.

When should I use 301 vs 302 redirect?

Use 301 Moved Permanently when a URL has permanently changed โ€” this transfers SEO value to the new URL. Use 302 Found for temporary redirects where the original URL will be used again, like during maintenance or A/B testing.

What causes a 502 Bad Gateway error?

A 502 occurs when a reverse proxy (like Nginx) receives an invalid response from the backend application server. Common causes include the application crashing, not running, timing out, or returning malformed responses. Check application logs and ensure the backend service is running.

How do I fix a 429 Too Many Requests error?

429 means you've exceeded the API's rate limit. Check the Retry-After response header for when to retry. Implement exponential backoff in your code, cache responses to reduce requests, and consider requesting a higher rate limit from the API provider.

What is the difference between 500 and 503 errors?

500 Internal Server Error indicates an unexpected condition that the server can't handle โ€” typically a bug in the code. 503 Service Unavailable means the server is temporarily unable to handle requests due to maintenance or overload, and the condition is expected to be temporary.

Related Tools

URL Encoder/Decoder JSON Formatter