HTTP Status Codes
HTTP status codes are three-digit response codes sent by a web server to indicate the result of an HTTP request.
When a browser requests a webpage, image, stylesheet, script, or other resource, the server responds with an HTTP status code. These codes indicate whether the request succeeded, requires further action, encountered a client-side problem, or failed because of a server-side problem.
HTTP Status Code Classes
The first digit of an HTTP status code identifies its response class. Status codes are grouped into five categories ranging from informational responses through server errors.
| Range | Category | Description |
|---|---|---|
100–199 | Informational | The request has been received and processing is continuing. |
200–299 | Successful | The request was successfully received, understood, and processed. |
300–399 | Redirection | Additional action or another location is involved in completing the request. |
400–499 | Client Error | The request cannot be completed because of a problem associated with the request. |
500–599 | Server Error | The server encountered a problem while attempting to fulfill the request. |
1xx Informational
Informational status codes indicate that the request has been received and that communication or processing is continuing. These responses are generally handled automatically by browsers and other HTTP clients.
| Code | Status | Description |
|---|---|---|
100 | Continue | The initial part of the request has been received and the client can continue sending the request. |
101 | Switching Protocols | The server is switching protocols as requested by the client. |
102 | Processing | The server has received the request and is processing it, but a final response is not yet available. |
103 | Early Hints | Provides preliminary response headers before the server sends the final response. |
2xx Successful
Successful status codes indicate that the server received and successfully handled the request.
| Code | Status | Description |
|---|---|---|
200 | OK | The request succeeded. |
201 | Created | The request succeeded and resulted in the creation of a new resource. |
202 | Accepted | The request was accepted for processing, but processing has not necessarily been completed. |
204 | No Content | The request succeeded and the response does not contain message content. |
206 | Partial Content | The server successfully returned part of the requested representation in response to a range request. |
3xx Redirection
Redirection status codes indicate that the client may need to use another location or take additional action to complete the request. Some 3xx responses are also used for HTTP caching.
| Code | Status | Description |
|---|---|---|
300 | Multiple Choices | Multiple representations or choices are available for the requested resource. |
301 | Moved Permanently | The resource has been assigned a new permanent URL. |
302 | Found | The resource is temporarily available at a different URL. |
303 | See Other | The client should retrieve another resource using a GET request. |
304 | Not Modified | A conditional request indicates that the cached representation can continue to be used. |
307 | Temporary Redirect | The resource is temporarily available at another URL while preserving the request method. |
308 | Permanent Redirect | The resource has permanently moved while preserving the request method. |
4xx Client Errors
Client error status codes indicate that the server cannot fulfill the request because of the request itself, authentication or authorization requirements, the requested resource, or another client-related condition.
| Code | Status | Description |
|---|---|---|
400 | Bad Request | The server cannot process the request because it considers the request invalid. |
401 | Unauthorized | The request lacks valid authentication credentials for the requested resource. |
403 | Forbidden | The server understood the request but refuses to fulfill it. |
404 | Not Found | The server cannot find the requested resource. |
405 | Method Not Allowed | The request method is known but is not supported for the target resource. |
408 | Request Timeout | The server did not receive a complete request within the time it was prepared to wait. |
409 | Conflict | The request conflicts with the current state of the target resource. |
410 | Gone | The requested resource is no longer available and the condition is expected to be permanent. |
413 | Content Too Large | The request content is larger than the server is willing or able to process. |
414 | URI Too Long | The requested URI is longer than the server is willing to interpret. |
415 | Unsupported Media Type | The request content uses a media type or encoding that the server does not support for this request. |
429 | Too Many Requests | The client has sent too many requests within a given period. |
5xx Server Errors
Server error status codes indicate that the server is aware that it encountered an error or cannot perform the requested operation.
| Code | Status | Description |
|---|---|---|
500 | Internal Server Error | The server encountered an unexpected condition that prevented it from fulfilling the request. |
501 | Not Implemented | The server does not support the functionality required to fulfill the request. |
502 | Bad Gateway | A server acting as a gateway or proxy received an invalid response from an upstream server. |
503 | Service Unavailable | The server is temporarily unable to handle the request. |
504 | Gateway Timeout | A gateway or proxy did not receive a timely response from an upstream server. |
505 | HTTP Version Not Supported | The server does not support the HTTP version used by the request. |
Common HTTP Status Codes
A smaller group of status codes appears frequently during normal website development, testing, redirects, and troubleshooting.
| Code | Status | Typical Meaning |
|---|---|---|
200 | OK | The requested resource was successfully returned. |
301 | Moved Permanently | The resource has permanently moved to another URL. |
302 | Found | The resource is temporarily being served from another URL. |
304 | Not Modified | The client's cached representation can be reused. |
400 | Bad Request | The server considers the request invalid. |
401 | Unauthorized | Authentication credentials are required or invalid. |
403 | Forbidden | The server refuses access to the requested resource. |
404 | Not Found | The requested resource could not be found. |
500 | Internal Server Error | An unexpected server-side error prevented the request from being completed. |
503 | Service Unavailable | The server is temporarily unable to handle the request. |
404 Not Found
The 404 Not Found response is one of the most familiar HTTP status codes. It indicates that the server cannot find a current representation of the requested resource or is not willing to disclose that one exists.
A 404 response can occur when a URL is typed incorrectly, a link points to a nonexistent location, a file has been deleted, or a resource has been moved without an appropriate redirect.
Websites can provide a custom 404 page to help visitors recover by offering useful navigation, a link to the home page, or another way to locate the desired content. The server should still return the actual 404 HTTP status code for a missing resource rather than returning a normal 200 OK response for the error page.
HTTP Redirects
Redirect status codes tell a browser or other client that a resource is available at another URL. The appropriate redirect depends on whether the move is permanent or temporary and whether the original HTTP request method needs to be preserved.
| Code | Type | Request Method |
|---|---|---|
301 | Permanent | Historically may be changed to GET by clients for non-GET requests. |
302 | Temporary | Historically may be changed to GET by clients for non-GET requests. |
303 | See Other | Directs the client to retrieve the other resource with GET, except for a HEAD request. |
307 | Temporary | Preserves the original request method. |
308 | Permanent | Preserves the original request method. |
Permanent redirects are commonly used when a webpage has permanently changed URLs. Correct redirects help visitors, browsers, and search engines reach the replacement resource.
HTTP Status Code Best Practices
- Return
200 OKonly when the request has been successfully handled as intended. - Return an appropriate
404 Not Foundstatus when a requested resource cannot be found. - Use permanent redirects when a resource has permanently moved and temporary redirects when the change is temporary.
- Avoid long redirect chains that make browsers request several URLs before reaching the final resource.
- Do not return a
200 OKstatus for a page that is actually reporting that a resource was not found. - Use
401 Unauthorizedfor HTTP authentication requirements and403 Forbiddenwhen the server refuses to fulfill an understood request. - Use
5xxresponses for server-side failures rather than presenting them as successful requests. - Check HTTP response headers when troubleshooting missing pages, redirects, caching, and server errors.
