When should I return 4xx versus 5xx?
Return 4xx when the client can fix the request, credentials, or timing. Return 5xx when the request was reasonable but the server or an upstream dependency failed anyway.
Reference
Start here when you know whether the request succeeded, redirected, or failed, but you still need the code that matches what actually happened.
Start with 404 diagnostics for deleted routes, stale links, and typos.
Use 401 when credentials are missing or invalid; pair with WWW-Authenticate.
Use 403 when identity is known but the action is not allowed.
Use 429 for throttling and communicate retry windows clearly.
Debug unknown origin failures and improve fallback behavior.
Signal maintenance or overload conditions with clear recovery hints.
Interim responses that indicate request progress before a final response is sent.
Best for: Protocol handshakes, continue flows, and early rendering hints.
Responses indicating the request was accepted and processed successfully.
Best for: Successful reads/writes where the request was accepted and processed.
Responses that tell clients to perform additional actions, usually by following a new URL.
Best for: URL changes and canonical migrations that preserve user navigation.
Client-side request issues such as invalid syntax, missing resources, or permission failures.
Best for: Client-side request issues like missing resources, invalid auth, or rate limits.
Server-side failures where the request was valid but the server could not complete it.
Best for: Server-side failures, upstream outages, and transient platform incidents.
Tip: press / to focus search.
The server received the request headers and the client should proceed to send the body. Learn when and how to use 100 Continue for efficient large uploads.
The server is switching to a different protocol as requested by the client. Learn about WebSocket upgrades and protocol negotiation.
The server has accepted the request and is processing it, but no response is available yet. Learn about this WebDAV status code for long-running operations.
The server sends preliminary response headers to help the client start preloading resources. Learn how 103 Early Hints improves page load performance.
Learn what HTTP 200 OK means, when servers return it, and how to handle successful responses in your applications.
Resource successfully created. Learn when to use 201 Created, proper response format, and best practices for creation endpoints.
The request was accepted for processing but not completed yet. Learn when to use 202 for asynchronous operations.
The request succeeded with no response body. Learn when to use 204 No Content for successful operations that don't return data.
The request has multiple possible responses. Learn when to use 300 Multiple Choices for content negotiation and alternative resource locations.
Learn what 301 redirect means, when to use it vs 302, and how to implement permanent redirects for SEO and URL changes.
Learn what 302 redirect means, when to use temporary vs permanent redirects, and how 302 differs from 301, 307, and 308.
Redirect to a different resource using GET. Learn when to use 303 to prevent form resubmission and implement the Post-Redirect-Get pattern.
Cached response is still valid. Learn how 304 Not Modified improves performance through conditional requests and caching.
Temporary redirect that preserves the HTTP method. Learn when to use 307 instead of 302 for method-sensitive redirects.
Permanent redirect that preserves the HTTP method. Learn when to use 308 instead of 301 for method-sensitive permanent redirects.
Learn what 400 Bad Request means when servers reject malformed requests. Understand common causes like invalid JSON, missing parameters, and how to debug.
Learn what 401 Unauthorized means, why it happens, and how to fix authentication errors. Complete guide with examples for APIs and web applications.
Reserved for future use in digital payment systems. Learn about this experimental status code and modern payment verification alternatives.
Learn what 403 Forbidden means, why access is denied, and how to fix permission errors. Complete guide with examples for APIs and web applications.
Learn what a 404 Not Found error means, why it happens, and how to fix it. Complete guide with examples for developers and users.
Learn what 405 Method Not Allowed means when HTTP methods are rejected. Understand the Allow header, proper API design, and how to handle method restrictions.
The server cannot produce a response matching the client's Accept headers. Learn about content negotiation and how to handle format mismatches.
Learn what 408 Request Timeout means when servers close idle connections. Understand timeout causes, client retry strategies, and connection management.
Learn what 409 Conflict means when requests conflict with server state. Understand concurrent updates, version conflicts, and optimistic locking strategies.
Learn what 410 Gone means and when resources are permanently removed. Understand the difference between 410 and 404, and SEO implications for deleted content.
The server doesn't meet one or more preconditions specified in request headers. Learn about conditional requests and how to prevent conflicts.
The request body is too large for the server to process. Learn about size limits and how to handle large uploads.
The requested URI exceeds the server's maximum length limit. Learn about URI length limits and how to handle oversized requests.
The server doesn't support the media type of the request. Learn about Content-Type headers and format requirements.
Learn what 422 Unprocessable Entity means for semantically invalid requests. Understand validation errors, the difference from 400, and proper error handling.
The resource is locked and cannot be accessed or modified. Learn about WebDAV locks and how to handle locked resources.
The server refuses to perform the request using the current protocol and requires the client to upgrade to a different protocol.
The server requires the request to be conditional. Learn when to use 428 Precondition Required to prevent lost updates and race conditions.
Learn what 429 Too Many Requests means, how rate limiting works, and how to handle API throttling in your applications.
The server refuses to process the request because header fields are too large. Learn how to handle and prevent 431 errors in your applications.
The requested resource is unavailable due to legal demands. Learn about 451 status code used for censorship and content blocking.
Learn what HTTP 500 Internal Server Error means, common causes, and how to fix it. Complete troubleshooting guide for developers.
The server doesn't support the functionality required to fulfill the request. Learn about unimplemented features.
Learn what 502 Bad Gateway means, why it happens, and how to fix it. Guide covering proxy errors, upstream failures, and troubleshooting.
Learn what 503 Service Unavailable means, why servers become unavailable, and how to handle temporary outages gracefully.
The gateway timed out waiting for a response from an upstream server. Learn about timeout issues and solutions.
Learn what 505 HTTP Version Not Supported means when servers reject protocol versions. Understand HTTP/1.1, HTTP/2 compatibility and version negotiation.
The server cannot store the representation needed to complete the request. Learn about storage limitations in WebDAV and file upload scenarios.
Cloudflare-specific error when the origin server returns an unexpected response. Learn about 520 errors and how to troubleshoot them.
Cloudflare-specific status code indicating the origin server refused the connection. Learn about this proxy error and how to troubleshoot it.
Cloudflare-specific error when unable to establish a TCP connection to the origin server. Learn how to diagnose and fix 522 timeout errors.
Cloudflare-specific error when the origin server's IP address is unreachable. Learn about DNS and routing issues causing 523 errors.
Cloudflare-specific error when the origin server takes too long to respond. Learn how to diagnose and fix 524 timeout errors.
Status codes are the shortest honest summary of what happened to a request. If your API returns the wrong one, clients retry the wrong thing, browsers behave differently, and debugging gets slower for everyone involved.
Most arguments about status codes happen when multiple answers sound plausible. This page helps narrow those cases down fast.
Return 4xx when the client can fix the request, credentials, or timing. Return 5xx when the request was reasonable but the server or an upstream dependency failed anyway.
Use 401 when the request lacks valid credentials and the client can authenticate again. Use 403 when the identity is known but still not allowed to do the thing it asked for.
Because some redirects preserve the original method and body while others switch the follow-up request to GET. The distinction affects forms, APIs, caches, and browser behavior.