HTTP state's codes attempts to give a standard response to every request received by the web server from a client. Such codes indicate whether the request was fulfilled, redirected, generated an error, or needed further actions, and such codes also can be distributed to five classes depending on the response rendered.
Every HTTP status code you need to know
server received request headers and continue with the request.
HTTP/1.1 100 Continue
Server switching protocols according to requested by client (e.g., upgrading to WebSocket ).
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
server received request and starting process but not available response
HTTP/1.1 102 Processing
This status code is primarily intended to be used with the Link header, letting the user agent start preloading resources while the server prepares a response or preconnect to an origin from which the page will need resources.
Request succeeded. The default success status.
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "success",
"data": { "message": "Request successful run and return output" }
}
Request succeeded and a new resource was created.
HTTP/1.1 201 Created
Location: /api/users/udaipur
Request accepted by server but is pending stage not complete.
HTTP/1.1 202 Accepted
Content-Type: application/json
{
"status": "processing",
"estimated-Completion-Time": "2024-10-30"
}
client send request to server but not return any content.
HTTP/1.1 204 No Content
Requested url redirect to another url permanent.
HTTP/1.1 301 Moved Permanently
Location: https://newdomain.com/video
Requested url redirect to another url temporarily.
HTTP/1.1 302 Found
Location: https://example.com/temporary-page-found
Resource hasn't changed since the last request.
HTTP/1.1 304 Not Modified
ETag: "81648761246715764681264871724681"
when client side error server not process request.
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"error": "Invalid parameters",
"details": {
"email": "Invalid email format please enter valid email "
}
}
When user request without token and actual token to authenticate website when show error.
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="example-token"
when payment is required for access some website features.
HTTP/1.1 402 Payment Required
Content-Type: application/json
{
"error": "Subscription required",
"plans": ["basic", "premium", "silver"]
}
Server understands request but refuses to authorize it.
HTTP/1.1 403 Forbidden
Content-Type: application/json
{
"error": "Access denied",
"message": "Insufficient permissions"
}
The requested resource could not be found.
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": "Resource not found",
"message": "The requested URL was not found"
}
HTTP method not allowed for this endpoint.
HTTP/1.1 405 Method Not Allowed
Allow: GET, POST
User has sent too many requests in a given time.
HTTP/1.1 429 Too Many Requests
Retry-After: 60
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
A generic error message when an unexpected condition was encountered.
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
{
"error": "Internal Server Error",
"message": "An unexpected error occurred",
"requestId": "abc-123-xyz"
}
Common causes: - Unhandled exceptions - Database connection issues - Configuration errors - Memory issues
the server not support request functionality to fullfill request requirement
HTTP/1.1 501 Not Implemented
Content-Type: application/json
{
"error": "Not Implemented ",
"message": "Thi api end point is not available please check endpoint ",
"availableDate": "2024-12-30"
}
when server received invalid server response from parent/upstrean server.
HTTP/1.1 502 Bad Gateway
Content-Type: application/json
{
"error": "Bad Gateway",
"message": "Invalid response from upstream server",
"retryAfter": 30
}
Common scenarios: - Microservice failures - Invalid proxy configurations - Network issues between servers
when server not handle request because already use 100% for other request when error generate.
HTTP/1.1 503 Service Unavailable
Retry-After: 300
Content-Type: application/json
{
"error": "Service Unavailable",
"message": "System is under maintenance",
"estimatedResolution": "2024-10-27T 15:30:00Z"
}
the server acting as gateway but not received response from parent/upstream server
HTTP/1.1 504 Gateway Timeout
Content-Type: application/json
{
"error": "Gateway Timeout again try",
"message": "Upstream server failed to respond in time",
"timeout": 30
}
the server is not support this version used in request please upgrade version
HTTP/1.1 505 HTTP Version Not Supported
Content-Type: application/json
{
"error": "HTTP Version Not Supported",
"message": "This server only supports HTTP/1.1 and HTTP/2",
"supportedVersions": ["HTTP/1.1", "HTTP/2"]
}
The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself.
HTTP/1.1 506 Variant Also Negotiates
Content-Type: application/json
{
"error": "Variant Also Negotiates",
"message": "Server configuration error in content negotiation"
}
when server memory is full and not handle and store more request data.
HTTP/1.1 507 Insufficient Storage
Content-Type: application/json
{
"error": "Insufficient Storage",
"message": "Not enough storage space to complete the request",
"availableSpace": "100MB",
"requiredSpace": "500MB"
}
The server detected an infinite loop while processing the request.
HTTP/1.1 508 Loop Detected
Content-Type: application/json
{
"error": "Loop Detected",
"message": "Infinite redirect loop detected",
"path": "/a -> /b -> /c -> /a"
}
Further extensions to the request are required for the server to fulfill it .
HTTP/1.1 510 Not Extended
Content-Type: application/json
{
"error": "Not Extended ",
"message": "requires protocol extension ",
"requiredExtensions": ["livedemo-ext"]
}
The client needs to authenticate to gain network access.
HTTP/1.1 511 Network Authentication Required
Content-Type: application/json
{
"error": "Authentication Required for access ",
"message": "first authenticate with user_id password to access the network",
"loginUrl": "https://wifi.newwifisetup.com/login"
}
Keep your servers healthy and your error handling robust! 🚀