4xx Client Errors HTTP Codes
The 4xx (Client Error) class of status codes indicates that the client made an invalid or unauthorized request. These are the most common errors developers encounter during API development and frontend navigation.
Bad Request
The server cannot process the request due to a client error.
Unauthorized
Authentication is required and has failed or has not yet been provided.
Payment Required
Reserved for future use. Used experimentally for digital micro-payments or exhausted API quotas.
Forbidden
The server understood the request but refuses to authorize it.
Not Found
The requested resource could not be found.
Method Not Allowed
The request method is known by the server but is not supported by the target resource.
Not Acceptable
The target resource does not have a current representation that would be acceptable to the user agent.
Proxy Authentication Required
Similar to 401 Unauthorized, but indicates that the client needs to authenticate itself in order to use a proxy.
Request Timeout
The server timed out waiting for the request.
Conflict
The request could not be completed due to a conflict with the current state of the resource.
Gone
Indicates that the target resource is no longer available at the origin server and that this condition is likely to be permanent.
Length Required
The server refuses to accept the request without a defined Content-Length.
Precondition Failed
The server does not meet one of the preconditions that the requester put on the request header fields.
Payload Too Large
The request entity is larger than limits defined by server.
URI Too Long
The URI provided was too long for the server to process.
Unsupported Media Type
The media format of the requested data is not supported by the server.
Range Not Satisfiable
The requested range cannot be satisfied (e.g., beyond the size of the resource).
Expectation Failed
The expectation given in the Expect request-header field could not be met by this server.
I'm a teapot
Any attempt to brew coffee with a teapot should result in the error code '418 I'm a teapot'.
Misdirected Request
The request was directed at a server that is not able to produce a response.
Unprocessable Entity
The request was well-formed but was unable to be followed due to semantic errors.
Locked
The resource that is being accessed is locked.
Failed Dependency
The request failed due to failure of a previous request (e.g., a PROPPATCH).
Too Early
Indicates that the server is unwilling to risk processing a request that might be replayed.
Upgrade Required
The client should switch to a different protocol such as TLS/1.3, given in the Upgrade header field.
Precondition Required
The origin server requires the request to be conditional.
Too Many Requests
The user has sent too many requests in a given amount of time (rate limiting).
Request Header Fields Too Large
The server is unwilling to process the request because either an individual header field, or all the header fields collectively, are too large.
Unavailable For Legal Reasons
A server operator has received a legal demand to deny access to a resource or to a set of resources.
💡Understanding 4xx Client Errors Codes
Why These Status Codes Matter
4xx errors cover critical application workflows including 404 missing routes (often solved with Nginx try_files for SPAs), 403 permission/CORS blocks, 401 expired JWT bearer tokens, 413 oversized file uploads, and 429 rate limiting.
Diagnostic & Troubleshooting Strategy
Verify the outgoing request URL, check Authorization headers, inspect CORS Access-Control-Allow-Origin settings, and ensure web servers like Nginx are configured to route deep links to index.html.
Frequently Asked Questions About 4xx Codes
What causes 404 Not Found errors on React/Vue single-page app refresh?
SPAs use client-side routing. When you refresh a deep link, the web server looks for a physical file at that path. Fix this by configuring Nginx 'try_files $uri $uri/ /index.html' or Apache .htaccess rewrite rules.
What is the difference between 401 Unauthorized and 403 Forbidden?
401 Unauthorized means authentication is required (missing or invalid token). 403 Forbidden means the server knows who you are, but you do not have permission to access the resource.
How do I fix 413 Payload Too Large when uploading files?
Increase the maximum allowed body size in your web server (e.g. 'client_max_body_size 50M;' in Nginx) and in your backend middleware (e.g. 'express.json({ limit: "50mb" })').