Additional HTTP status codes from popular web servers and unofficial sources that extend the standard IANA HTTP status code set.
The extra status codes provide access to server-specific and unofficial HTTP status codes.
/**
* Extra status codes organized by category
*/
interface ExtraStatusCodes {
unofficial: UnofficialStatusCodes;
iis: IISStatusCodes;
nginx: NGINXStatusCodes;
cloudflare: CloudflareStatusCodes;
}Usage Examples:
import status from "http-status";
// Access extra status codes
console.log(status.extra.nginx.NO_RESPONSE); // 444
console.log(status.extra.cloudflare[520]); // "Unknown Error"
console.log(status.extra.unofficial.IM_A_TEAPOT); // 418 (also available in main status)
console.log(status.extra.iis.LOGIN_TIME_OUT); // 440
// Get detailed information
console.log(status.extra.nginx["444_NAME"]); // "NO_RESPONSE"
console.log(status.extra.nginx["444_MESSAGE"]); // "Used internally to instruct the server..."Non-standard status codes that are not specified by any official standard but are used by various applications.
/**
* Unofficial status codes not specified by any standard
*/
interface UnofficialStatusCodes {
103: "Checkpoint";
CHECKPOINT: 103;
"103_NAME": "CHECKPOINT";
"103_MESSAGE": "Used in the resumable requests proposal to resume aborted PUT or POST requests.";
"103_CLASS": "1xx";
218: "This is fine";
THIS_IS_FINE: 218;
"218_NAME": "THIS_IS_FINE";
"218_MESSAGE": "Used as a catch-all error condition for allowing response bodies to flow through Apache when ProxyErrorOverride is enabled.";
"218_CLASS": "2xx";
419: "Page Expired";
PAGE_EXPIRED: 419;
"419_NAME": "PAGE_EXPIRED";
"419_MESSAGE": "Used by the Laravel Framework when a CSRF Token is missing or expired.";
"419_CLASS": "4xx";
420: "Enhance Your Calm";
ENHANCE_YOUR_CALM: 420;
"420_NAME": "ENHANCE_YOUR_CALM";
"420_MESSAGE": "Returned by version 1 of the Twitter Search and Trends API when the client is being rate limited.";
"420_CLASS": "4xx";
450: "Blocked by Windows Parental Controls";
BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS: 450;
"450_NAME": "BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS";
"450_MESSAGE": "The Microsoft extension code indicated when Windows Parental Controls are turned on and are blocking access to the requested webpage.";
"450_CLASS": "4xx";
498: "Invalid Token";
INVALID_TOKEN: 498;
"498_NAME": "INVALID_TOKEN";
"498_MESSAGE": "Returned by ArcGIS for Server. Code 498 indicates an expired or otherwise invalid token.";
"498_CLASS": "4xx";
499: "Token Required";
TOKEN_REQUIRED: 499;
"499_NAME": "TOKEN_REQUIRED";
"499_MESSAGE": "Returned by ArcGIS for Server. Code 499 indicates that a token is required but was not submitted.";
"499_CLASS": "4xx";
509: "Bandwidth Limit Exceeded";
BANDWIDTH_LIMIT_EXCEEDED: 509;
"509_NAME": "BANDWIDTH_LIMIT_EXCEEDED";
"509_MESSAGE": "The server has exceeded the bandwidth specified by the server administrator.";
"509_CLASS": "5xx";
530: "Site is frozen";
SITE_IS_FROZEN: 530;
"530_NAME": "SITE_IS_FROZEN";
"530_MESSAGE": "Used by the Pantheon web platform to indicate a site that has been frozen due to inactivity.";
"530_CLASS": "5xx";
598: "Network read timeout error";
NETWORK_READ_TIMEOUT_ERROR: 598;
"598_NAME": "NETWORK_READ_TIMEOUT_ERROR";
"598_MESSAGE": "Used by some HTTP proxies to signal a network read timeout behind the proxy to a client in front of the proxy.";
"598_CLASS": "5xx";
}Microsoft's Internet Information Services (IIS) web server expands the 4xx error space to signal errors with the client's request.
/**
* IIS-specific status codes
*/
interface IISStatusCodes {
440: "Login Time-out";
LOGIN_TIME_OUT: 440;
"440_NAME": "LOGIN_TIME_OUT";
"440_MESSAGE": "The client's session has expired and must log in again.";
"440_CLASS": "4xx";
449: "Retry With";
RETRY_WITH: 449;
"449_NAME": "RETRY_WITH";
"449_MESSAGE": "The server cannot honour the request because the user has not provided the required information.";
"449_CLASS": "4xx";
451: "Redirect";
REDIRECT: 451;
"451_NAME": "REDIRECT";
"451_MESSAGE": "Used in Exchange ActiveSync when either a more efficient server is available or the server cannot access the users' mailbox.";
"451_CLASS": "4xx";
}The NGINX web server software expands the 4xx error space to signal issues with the client's request.
/**
* NGINX-specific status codes
*/
interface NGINXStatusCodes {
444: "No Response";
NO_RESPONSE: 444;
"444_NAME": "NO_RESPONSE";
"444_MESSAGE": "Used internally to instruct the server to return no information to the client and close the connection immediately.";
"444_CLASS": "4xx";
494: "Request header too large";
REQUEST_HEADER_TOO_LARGE: 494;
"494_NAME": "REQUEST_HEADER_TOO_LARGE";
"494_MESSAGE": "Client sent too large request or too long header line.";
"494_CLASS": "4xx";
495: "SSL Certificate Error";
SSL_CERTIFICATE_ERROR: 495;
"495_NAME": "SSL_CERTIFICATE_ERROR";
"495_MESSAGE": "An expansion of the 400 Bad Request response code, used when the client has provided an invalid client certificate.";
"495_CLASS": "4xx";
496: "SSL Certificate Required";
SSL_CERTIFICATE_REQUIRED: 496;
"496_NAME": "SSL_CERTIFICATE_REQUIRED";
"496_MESSAGE": "An expansion of the 400 Bad Request response code, used when a client certificate is required but not provided.";
"496_CLASS": "4xx";
497: "HTTP Request Sent to HTTPS Port";
HTTP_REQUEST_SENT_TO_HTTPS_PORT: 497;
"497_NAME": "HTTP_REQUEST_SENT_TO_HTTPS_PORT";
"497_MESSAGE": "An expansion of the 400 Bad Request response code, used when the client has made a HTTP request to a port listening for HTTPS requests.";
"497_CLASS": "4xx";
499: "Client Closed Request";
CLIENT_CLOSED_REQUEST: 499;
"499_NAME": "CLIENT_CLOSED_REQUEST";
"499_MESSAGE": "Used when the client has closed the request before the server could send a response.";
"499_CLASS": "4xx";
}Cloudflare's reverse proxy service expands the 5xx series of errors space to signal issues with the origin server.
/**
* Cloudflare-specific status codes
*/
interface CloudflareStatusCodes {
520: "Unknown Error";
UNKNOWN_ERROR: 520;
"520_NAME": "UNKNOWN_ERROR";
"520_MESSAGE": "The 520 error is used as a \"catch-all response for when the origin server returns something unexpected\", listing connection resets, large headers, and empty or invalid responses as common triggers.";
"520_CLASS": "5xx";
521: "Web Server Is Down";
WEB_SERVER_IS_DOWN: 521;
"521_NAME": "WEB_SERVER_IS_DOWN";
"521_MESSAGE": "The origin server has refused the connection from Cloudflare.";
"521_CLASS": "5xx";
522: "Connection Timed Out";
CONNECTION_TIMED_OUT: 522;
"522_NAME": "CONNECTION_TIMED_OUT";
"522_MESSAGE": "Cloudflare could not negotiate a TCP handshake with the origin server.";
"522_CLASS": "5xx";
523: "Origin Is Unreachable";
ORIGIN_IS_UNREACHABLE: 523;
"523_NAME": "ORIGIN_IS_UNREACHABLE";
"523_MESSAGE": "Cloudflare could not reach the origin server.";
"523_CLASS": "5xx";
524: "A Timeout Occurred";
A_TIMEOUT_OCCURRED: 524;
"524_NAME": "A_TIMEOUT_OCCURRED";
"524_MESSAGE": "Cloudflare was able to complete a TCP connection to the origin server, but did not receive a timely HTTP response.";
"524_CLASS": "5xx";
525: "SSL Handshake Failed";
SSL_HANDSHAKE_FAILED: 525;
"525_NAME": "SSL_HANDSHAKE_FAILED";
"525_MESSAGE": "Cloudflare could not negotiate a SSL/TLS handshake with the origin server.";
"525_CLASS": "5xx";
526: "Invalid SSL Certificate";
INVALID_SSL_CERTIFICATE: 526;
"526_NAME": "INVALID_SSL_CERTIFICATE";
"526_MESSAGE": "Cloudflare could not validate the SSL/TLS certificate that the origin server presented.";
"526_CLASS": "5xx";
527: "Railgun Error";
RAILGUN_ERROR: 527;
"527_NAME": "RAILGUN_ERROR";
"527_MESSAGE": "Error 527 indicates that the request timed out or failed after the WAN connection had been established.";
"527_CLASS": "5xx";
}Usage Examples:
import status from "http-status";
// Handle server-specific status codes
function handleResponse(statusCode: number) {
switch (statusCode) {
// Standard codes
case status.OK:
return "Success";
case status.NOT_FOUND:
return "Resource not found";
// NGINX-specific
case status.extra.nginx.NO_RESPONSE:
return "NGINX: No response";
case status.extra.nginx.SSL_CERTIFICATE_ERROR:
return "NGINX: SSL certificate error";
// Cloudflare-specific
case status.extra.cloudflare.UNKNOWN_ERROR:
return "Cloudflare: Unknown error";
case status.extra.cloudflare.WEB_SERVER_IS_DOWN:
return "Cloudflare: Origin server down";
// IIS-specific
case status.extra.iis.LOGIN_TIME_OUT:
return "IIS: Login timeout";
default:
return "Unknown status code";
}
}