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–199InformationalThe request has been received and processing is continuing.
200–299SuccessfulThe request was successfully received, understood, and processed.
300–399RedirectionAdditional action or another location is involved in completing the request.
400–499Client ErrorThe request cannot be completed because of a problem associated with the request.
500–599Server ErrorThe 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
100ContinueThe initial part of the request has been received and the client can continue sending the request.
101Switching ProtocolsThe server is switching protocols as requested by the client.
102ProcessingThe server has received the request and is processing it, but a final response is not yet available.
103Early HintsProvides 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
200OKThe request succeeded.
201CreatedThe request succeeded and resulted in the creation of a new resource.
202AcceptedThe request was accepted for processing, but processing has not necessarily been completed.
204No ContentThe request succeeded and the response does not contain message content.
206Partial ContentThe 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
300Multiple ChoicesMultiple representations or choices are available for the requested resource.
301Moved PermanentlyThe resource has been assigned a new permanent URL.
302FoundThe resource is temporarily available at a different URL.
303See OtherThe client should retrieve another resource using a GET request.
304Not ModifiedA conditional request indicates that the cached representation can continue to be used.
307Temporary RedirectThe resource is temporarily available at another URL while preserving the request method.
308Permanent RedirectThe 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
400Bad RequestThe server cannot process the request because it considers the request invalid.
401UnauthorizedThe request lacks valid authentication credentials for the requested resource.
403ForbiddenThe server understood the request but refuses to fulfill it.
404Not FoundThe server cannot find the requested resource.
405Method Not AllowedThe request method is known but is not supported for the target resource.
408Request TimeoutThe server did not receive a complete request within the time it was prepared to wait.
409ConflictThe request conflicts with the current state of the target resource.
410GoneThe requested resource is no longer available and the condition is expected to be permanent.
413Content Too LargeThe request content is larger than the server is willing or able to process.
414URI Too LongThe requested URI is longer than the server is willing to interpret.
415Unsupported Media TypeThe request content uses a media type or encoding that the server does not support for this request.
429Too Many RequestsThe 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
500Internal Server ErrorThe server encountered an unexpected condition that prevented it from fulfilling the request.
501Not ImplementedThe server does not support the functionality required to fulfill the request.
502Bad GatewayA server acting as a gateway or proxy received an invalid response from an upstream server.
503Service UnavailableThe server is temporarily unable to handle the request.
504Gateway TimeoutA gateway or proxy did not receive a timely response from an upstream server.
505HTTP Version Not SupportedThe 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
200OKThe requested resource was successfully returned.
301Moved PermanentlyThe resource has permanently moved to another URL.
302FoundThe resource is temporarily being served from another URL.
304Not ModifiedThe client's cached representation can be reused.
400Bad RequestThe server considers the request invalid.
401UnauthorizedAuthentication credentials are required or invalid.
403ForbiddenThe server refuses access to the requested resource.
404Not FoundThe requested resource could not be found.
500Internal Server ErrorAn unexpected server-side error prevented the request from being completed.
503Service UnavailableThe 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
301PermanentHistorically may be changed to GET by clients for non-GET requests.
302TemporaryHistorically may be changed to GET by clients for non-GET requests.
303See OtherDirects the client to retrieve the other resource with GET, except for a HEAD request.
307TemporaryPreserves the original request method.
308PermanentPreserves 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 OK only when the request has been successfully handled as intended.
  • Return an appropriate 404 Not Found status 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 OK status for a page that is actually reporting that a resource was not found.
  • Use 401 Unauthorized for HTTP authentication requirements and 403 Forbidden when the server refuses to fulfill an understood request.
  • Use 5xx responses for server-side failures rather than presenting them as successful requests.
  • Check HTTP response headers when troubleshooting missing pages, redirects, caching, and server errors.