HTTP Status Codes Reference

Complete guide to HTTP response status codes organized by category

Status Code Categories

HTTP status codes are grouped into five categories based on the first digit:

Range Category Meaning Common Codes
1xx Informational Request received, continuing process 100, 101
2xx Success Request successfully received, understood, and accepted 200, 201, 204
3xx Redirection Further action needed to complete the request 301, 302, 304
4xx Client Error Request contains bad syntax or cannot be fulfilled 400, 401, 404
5xx Server Error Server failed to fulfill a valid request 500, 502, 503

The following sections list all standard HTTP status codes organized by category. Each table provides a quick reference, while the most commonly encountered codes include detailed explanations with example request/response pairs to illustrate their practical usage.

1xx Informational

Provisional responses indicating the request was received and the process is continuing.

Code Name Description RFC
100 Continue Server has received request headers; client should send body 9110 §15.2.1
101 Switching Protocols Server is switching protocols as requested (e.g., to WebSocket) 9110 §15.2.2
103 Early Hints Server sends preliminary headers before final response 8297

100 Continue

Tells the client to continue sending the request body. Used when client sends Expect: 100-continue header to check if server will accept a large request before sending it.

Use case: Large file uploads where you want server validation before transmitting

101 Switching Protocols

Server agrees to switch protocols as requested via the Upgrade header. Commonly used for WebSocket connections.

Use case: Upgrading HTTP connection to WebSocket

2xx Success

The request was successfully received, understood, and accepted.

Code Name Description RFC
200 OK Standard success response; meaning varies by HTTP method 9110 §15.3.1
201 Created Request fulfilled, new resource created 9110 §15.3.2
202 Accepted Request accepted but not yet processed (async) 9110 §15.3.3
204 No Content Success, but no body to return 9110 §15.3.5
206 Partial Content Partial resource returned (range request) 9110 §15.3.7

200 OK

The most common success status. For GET, the resource is in the body. For POST, the result of the action is in the body.

Use case: Successful GET requests, form submissions, API calls

201 Created

A new resource has been created. The Location header should contain the URI of the new resource.

Use case: POST request that creates a new record/resource

204 No Content

Request succeeded but there's nothing to return. The response must not include a body.

Use case: DELETE requests, PUT/PATCH that don't need to return data

3xx Redirection

Further action is needed to complete the request. Usually involves following a Location header.

Code Name Description RFC
301 Moved Permanently Resource permanently moved; update bookmarks 9110 §15.4.2
302 Found Resource temporarily at different URI 9110 §15.4.3
303 See Other Redirect to GET another resource (after POST) 9110 §15.4.4
304 Not Modified Resource unchanged; use cached version 9110 §15.4.5
307 Temporary Redirect Temporary redirect, preserve HTTP method 9110 §15.4.8
308 Permanent Redirect Permanent redirect, preserve HTTP method 9110 §15.4.9

301 Moved Permanently

The resource has permanently moved to a new URL. Clients should update their links. Search engines will transfer SEO value to the new URL.

Use case: Site migrations, URL restructuring, enforcing canonical URLs

304 Not Modified

Used for caching. Client's cached version is still valid, no need to transfer the body again.

Use case: Conditional GET with If-None-Match or If-Modified-Since

307 Temporary Redirect

Like 302, but guarantees the HTTP method won't change. A POST remains a POST after redirect.

Use case: Temporary maintenance redirects, preserving POST data

4xx Client Error

The request contains errors or cannot be fulfilled due to client-side issues.

Code Name Description RFC
400 Bad Request Malformed syntax, invalid parameters 9110 §15.5.1
401 Unauthorized Authentication required 9110 §15.5.2
403 Forbidden Server refuses to authorize (even with auth) 9110 §15.5.4
404 Not Found Resource does not exist 9110 §15.5.5
405 Method Not Allowed HTTP method not supported for this resource 9110 §15.5.6
409 Conflict Request conflicts with current resource state 9110 §15.5.10
406 Not Acceptable Content negotiation failed (Accept headers) 9110 §15.5.7
408 Request Timeout Client took too long to send request 9110 §15.5.9
410 Gone Resource permanently deleted (no forwarding) 9110 §15.5.11
411 Length Required Content-Length header required 9110 §15.5.12
412 Precondition Failed Conditional request failed (If-Match, etc.) 9110 §15.5.13
413 Content Too Large Request body exceeds server limit 9110 §15.5.14
414 URI Too Long Request URI exceeds server limit 9110 §15.5.15
415 Unsupported Media Type Content-Type not supported by server 9110 §15.5.16
418 I'm a Teapot Server refuses to brew coffee (April Fools' joke) 2324 §2.3.2
422 Unprocessable Content Syntax OK but semantically invalid 9110 §15.5.21
428 Precondition Required Conditional request required (optimistic locking) 6585 §3
429 Too Many Requests Rate limit exceeded 6585 §4
451 Unavailable For Legal Reasons Blocked due to legal demands (censorship) 7725

400 Bad Request

The server cannot process the request due to malformed syntax, invalid parameters, or bad framing. The response body should explain the problem.

Use case: Invalid JSON, missing required fields, malformed query strings

401 Unauthorized

Authentication is required. Must include a WWW-Authenticate header indicating how to authenticate.

Use case: Missing or expired credentials, invalid API key

403 Forbidden

Server understood the request but refuses to authorize it. Authentication won't help—the user doesn't have permission.

Use case: Accessing admin resources as regular user, IP blocked

404 Not Found

The requested resource could not be found. May be temporary or permanent (consider 410 for permanently gone).

Use case: Invalid URL, deleted resource, typo in path

422 Unprocessable Content

Request syntax is correct, but the server can't process the contained instructions. Common for validation errors.

Use case: Email already exists, password too weak, business rule violation

429 Too Many Requests

Rate limit exceeded. Should include Retry-After header indicating when to retry.

Use case: API rate limiting, brute force protection

5xx Server Error

The server failed to fulfill a valid request. These errors are the server's fault.

Code Name Description RFC
500 Internal Server Error Generic server error (catch-all) 9110 §15.6.1
501 Not Implemented Server doesn't support the functionality 9110 §15.6.2
502 Bad Gateway Invalid response from upstream server 9110 §15.6.3
503 Service Unavailable Server temporarily unavailable (overload/maintenance) 9110 §15.6.4
504 Gateway Timeout Upstream server didn't respond in time 9110 §15.6.5
505 HTTP Version Not Supported Server doesn't support the HTTP version used 9110 §15.6.6
507 Insufficient Storage Server cannot store the representation (WebDAV) 4918 §11.5
508 Loop Detected Infinite loop detected processing request (WebDAV) 5842 §7.2
511 Network Authentication Required Client needs to authenticate with network (captive portal) 6585 §6

500 Internal Server Error

Generic error when the server encounters an unexpected condition. Avoid exposing internal details in production.

Use case: Unhandled exceptions, database errors, configuration issues

502 Bad Gateway

Server acting as gateway/proxy received an invalid response from upstream. Common with reverse proxies.

Use case: Backend server crashed, upstream returned malformed response

503 Service Unavailable

Server is temporarily unable to handle requests. Should include Retry-After header when possible.

Use case: Planned maintenance, server overloaded, dependency down

Which Status Code Should I Use?

Choosing the right status code helps clients understand what happened and how to respond. This guide covers common scenarios for both traditional web applications and REST APIs.

General Web Scenarios

These status codes apply across all types of web applications:

Scenario Status Code Notes
Request succeeded, returning data 200 OK Most common success response
Created a new resource 201 Created Include Location header with new resource URL
Succeeded but nothing to return 204 No Content Good for DELETE or updates without response body
Resource moved permanently 301 Moved Permanently Search engines update their index
Resource moved temporarily 307 Temporary Redirect Preserves HTTP method (unlike 302)
Invalid data format from client 400 Bad Request Malformed JSON, missing parameters
Client needs to authenticate 401 Unauthorized Include WWW-Authenticate header
Authenticated but not authorized 403 Forbidden Valid credentials, insufficient permissions
Resource doesn't exist 404 Not Found Also used to hide existence of protected resources
Validation error (business rules) 422 Unprocessable Content Syntax OK but semantically invalid
Server error (your bug) 500 Internal Server Error Log details server-side, don't expose to client
Upstream service failed 502 Bad Gateway Backend or proxy received invalid response
Server overloaded or maintenance 503 Service Unavailable Include Retry-After header when possible

REST API: CRUD Operations

REST APIs map HTTP methods to Create, Read, Update, and Delete operations. The status code should reflect both the operation type and its outcome.

GET (Read)

ScenarioStatusNotes
Single resource found200 OKReturn resource in body
Collection found (even if empty)200 OKReturn array, never 404 for empty collection
Resource not found404 Not Found
User can't access this resource403 or 404Use 404 to hide existence
Client cache is still valid304 Not ModifiedNo body, client uses cached version

POST (Create)

ScenarioStatusNotes
Resource created201 CreatedInclude Location header with new URL
Action completed, no resource created200 or 204For RPC-style endpoints
Processing asynchronously202 AcceptedReturn status/polling URL in body
Duplicate resource409 ConflictResource with same identifier exists
Malformed request body400 Bad RequestJSON parse error, missing fields
Invalid data (business rules)422 UnprocessableValid JSON but fails validation

PUT (Replace) & PATCH (Partial Update)

ScenarioStatusNotes
Update successful200 OKReturn updated resource
Update successful, no body204 No ContentWhen client doesn't need response
PUT created new resource201 CreatedOnly if client provides ID
Resource doesn't exist404 Not FoundPATCH always requires existing resource
Concurrent modification409 ConflictETag mismatch or version conflict
If-Match header missing428 Precondition RequiredWhen optimistic locking is required
Precondition failed412 Precondition FailedIf-Match or If-Unmodified-Since failed
Wrong Content-Type for PATCH415 Unsupported Media Typee.g., expected JSON Patch

DELETE

ScenarioStatusNotes
Deleted successfully200 or 204200 if returning deleted resource
Resource doesn't exist404 or 204204 for idempotent behavior
Delete queued202 AcceptedFor async deletion
Has dependencies409 ConflictCan't delete due to references
Delete not allowed405 Method Not AllowedResource can never be deleted

Error Handling Patterns

Consistent error responses help API consumers handle failures gracefully:

Error TypeStatusWhen to Use
Syntax error400 Bad RequestJSON parse error, malformed request
Missing required field400 or 422400 if structural, 422 if validation
Field validation failure422 UnprocessableEmail format, range checks, etc.
No credentials401 UnauthorizedNo API key or token provided
Invalid credentials401 UnauthorizedBad or expired token
Insufficient permissions403 ForbiddenValid token but wrong role/scope
Rate limited429 Too Many RequestsInclude Retry-After header
Payload too large413 Content Too LargeFile upload exceeds limit
URL too long414 URI Too LongQuery string too large
Wrong Accept header406 Not AcceptableCan't produce requested format

Idempotency

Idempotent operations produce the same result regardless of how many times they're called. This is important for retry logic and reliability. GET, PUT, and DELETE should be idempotent; POST typically is not.

ScenarioIdempotent ResponseStrict Response
DELETE already-deleted resource204 No Content404 Not Found
PUT same data twice200 OK (same result each time)
POST creating duplicate409 Conflict (POST is not idempotent)

The idempotent approach (returning success for already-deleted resources) simplifies client retry logic, since clients don't need to distinguish between "deleted now" and "already deleted."