HTTP Status Codes Guide: Every Code Explained
Every HTTP response begins with a three-digit status code that tells the client exactly what happened with their request. Whether you are building REST APIs, debugging a failed webhook, or wondering why your browser shows a blank page, understanding HTTP status codes is fundamental to web development. Yet many developers only know a handful - 200, 404, and 500 - and miss the nuances that make APIs predictable and debuggable.
This guide covers every status code category with practical examples and debugging advice. Bookmark our HTTP Status Codes reference tool for quick lookups when you are in the middle of debugging.
1xx: Informational Responses
1xx codes indicate that the server has received the request and is continuing to process it. You rarely see these in typical web development, but they matter for advanced use cases.
- 100 Continue: The server has received the request headers and the client should proceed to send the request body. Used when clients send an
Expect: 100-continueheader before uploading large payloads, allowing the server to reject the request before the body is transmitted. - 101 Switching Protocols: The server is switching to a different protocol as requested by the client. The most common use case is upgrading an HTTP connection to a WebSocket connection.
- 103 Early Hints: Allows the server to send preliminary headers (like
Linkheaders for preloading resources) before the final response. This helps browsers start fetching CSS and JavaScript earlier.
2xx: Success Codes
2xx codes indicate the request was successfully received, understood, and accepted. Choosing the right 2xx code for your API responses makes them more predictable for consumers.
- 200 OK: The standard success response. Use for GET requests returning data, PUT/PATCH requests returning the updated resource, and any other successful operation that returns a body.
- 201 Created: A new resource was successfully created. Use for POST requests that create entities. Include a
Locationheader with the URL of the new resource. - 204 No Content: The request succeeded but there is no body to return. Perfect for DELETE operations and updates where the client does not need the response body.
- 206 Partial Content: The server is returning only part of the resource, as requested via a
Rangeheader. Used for resumable downloads and video streaming.
3xx: Redirection Codes
3xx codes tell the client that further action is needed to complete the request, usually following a redirect to a different URL.
- 301 Moved Permanently: The resource has permanently moved. Browsers cache this redirect and search engines transfer link equity to the new URL. Use for domain changes and permanent URL restructuring.
- 302 Found: Temporary redirect. The resource is temporarily at a different URL. Browsers do not cache this redirect. Use for maintenance pages or temporary routing.
- 304 Not Modified: The resource has not changed since the client last requested it (based on
If-None-MatchorIf-Modified-Sinceheaders). The client should use its cached version. Critical for performance. - 307 Temporary Redirect: Like 302, but guarantees the request method and body will not change. If you POST to a URL that returns 307, the browser will POST to the new URL (not downgrade to GET).
- 308 Permanent Redirect: Like 301, but preserves the request method. The permanent version of 307.
4xx: Client Error Codes
4xx codes indicate the client sent a bad request. These are the most important codes for API design because they guide developers to fix their requests.
- 400 Bad Request: The server cannot process the request due to malformed syntax, invalid parameters, or missing required fields. Include a descriptive error message in the response body explaining what is wrong.
- 401 Unauthorized: The client has not provided valid authentication credentials. Despite the name, this is about authentication (identity), not authorization (permission). Return a
WWW-Authenticateheader indicating the expected auth scheme. - 403 Forbidden: The client is authenticated but does not have permission to access the resource. The server knows who you are but will not let you in.
- 404 Not Found: The requested resource does not exist. Can also be used intentionally to hide the existence of resources from unauthorized users (instead of returning 403).
- 405 Method Not Allowed: The HTTP method is not supported for this URL. For example, trying to DELETE a read-only resource. Include an
Allowheader listing valid methods. - 409 Conflict: The request conflicts with the current state of the server. Common for duplicate creation attempts, optimistic concurrency conflicts, or conflicting updates.
- 422 Unprocessable Entity: The request is well-formed but semantically invalid. For example, a JSON body that parses correctly but contains a negative value for an age field. Increasingly popular as a more specific alternative to 400.
- 429 Too Many Requests: Rate limit exceeded. Include a
Retry-Afterheader indicating how long the client should wait.
5xx: Server Error Codes
5xx codes indicate something went wrong on the server side. These should always be logged and investigated.
- 500 Internal Server Error: A generic catch-all for unexpected server errors. Never expose stack traces or internal details in production responses. Log the full error server-side for debugging.
- 502 Bad Gateway: A reverse proxy or load balancer received an invalid response from the upstream server. Usually means the backend service is down or returning garbage.
- 503 Service Unavailable: The server is temporarily unable to handle requests, typically due to maintenance or overload. Include a
Retry-Afterheader when possible. - 504 Gateway Timeout: The reverse proxy or gateway did not receive a response from the upstream server within the allowed time. Usually indicates a slow database query, external API timeout, or infinite loop.
Best Practices for API Status Codes
- Be specific. Use 201 for creation, 204 for deletion, and 409 for conflicts rather than returning 200 for everything. Specific codes make APIs self-documenting.
- Include error details. For 4xx errors, return a structured error body with a machine-readable error code, a human-readable message, and the specific field or parameter that caused the error.
- Do not leak internals. 5xx responses in production should never include stack traces, database queries, or internal file paths. Log those server-side.
- Use Retry-After. For 429 and 503 responses, tell clients when they can retry. This prevents thundering herd problems.
- Document your codes. Your API documentation should list every status code each endpoint can return and what each means in context.
Look Up Any Status Code
Our HTTP Status Codes tool provides instant lookup for any status code with descriptions, common causes, and debugging tips. Keep it bookmarked for your next debugging session.