🌐 Complete HTTP Status Codes Guide

Master Web Development with Comprehensive Status Code Reference

Understanding HTTP Status Codes

HTTP status codes are three-digit numbers returned by web servers to indicate the result of a client's request. They are essential for web development, API design, and troubleshooting. Each code provides specific information about what happened when processing the request.

1xx - Informational

Request received, continuing process

2xx - Success

Request successfully received and processed

3xx - Redirection

Further action needed to complete request

4xx - Client Error

Request contains bad syntax or cannot be fulfilled

5xx - Server Error

Server failed to fulfill valid request

Status Code Meaning Description & Examples
100 Continue Client should continue sending the request body.
curl -X POST -H "Expect: 100-continue" -d "data" /api/upload
Used when uploading large files to check if server can accept the request before sending data.
101 Switching Protocols Server agrees to switch protocols as requested by client.
WebSocket handshake: HTTP → WebSocket protocol
Essential for real-time applications like chat systems, live updates, and gaming.
102 Processing Server has received and is processing the request, but no response is available yet.
Long-running operations like data processing or file conversion
Prevents client timeout during lengthy server operations.
200 OK Standard response for successful HTTP requests.
GET /api/users → Returns user list successfully
Most common success response for GET, POST, PUT requests with content.
201 Created Request succeeded and a new resource has been created.
POST /api/users → New user account created
RESTful APIs when creating new resources like users, posts, or records.
202 Accepted Request accepted for processing, but processing not completed.
POST /api/batch-process → Job queued for background processing
Asynchronous operations, batch processing, email sending queues.
204 No Content Request succeeded, but no content to return.
DELETE /api/users/123 → User deleted successfully
DELETE operations, PUT updates that don't return data, successful form submissions.
206 Partial Content Server is delivering only part of the resource due to a range header.
Video streaming: bytes 200-1023/2048
Video streaming, file downloads with resume capability, pagination.
301 Moved Permanently Resource has moved permanently to a new URL.
example.com/old-page → example.com/new-page
Website restructuring, domain changes, SEO URL optimization.
302 Found (Temporary Redirect) Resource temporarily moved to a different URL.
Maintenance page redirect, A/B testing redirects
Temporary maintenance, load balancing, feature flags.
304 Not Modified Cached version is still valid, no need to re-download.
If-Modified-Since header check → Resource unchanged
Browser caching, CDN optimization, bandwidth saving.
307 Temporary Redirect Temporary redirect that preserves the request method.
POST request redirected while maintaining POST method
Maintaining HTTP method during temporary redirects.
308 Permanent Redirect Permanent redirect that preserves the request method.
API versioning: /v1/users → /v2/users (keeping POST)
API versioning, permanent URL changes while preserving HTTP methods.
400 Bad Request Server couldn't understand the request due to invalid syntax.
Invalid JSON: {"name": "John", "age": } → Missing value
Malformed JSON, missing required fields, invalid data types.
401 Unauthorized Authentication is required but not provided or invalid.
API call without Authorization header or invalid token
Missing login credentials, expired tokens, invalid API keys.
403 Forbidden User authenticated but doesn't have permission to access resource.
Regular user trying to access admin panel
Role-based access control, insufficient permissions, blocked IP addresses.
404 Not Found Requested resource not found on the server.
GET /api/users/999 → User ID 999 doesn't exist
Broken links, deleted resources, typos in URLs, non-existent API endpoints.
405 Method Not Allowed HTTP method not supported for the requested resource.
DELETE /api/users → Endpoint only supports GET and POST
API design restrictions, read-only endpoints, method-specific handlers.
409 Conflict Request conflicts with current server state.
Creating user with email that already exists
Duplicate entries, version conflicts, concurrent modifications.
410 Gone Resource was available previously but has been permanently removed.
Deleted blog post, discontinued product page
Permanently deleted content, discontinued services, expired promotions.
422 Unprocessable Entity Request is well-formed but contains semantic errors.
Valid JSON but email format is invalid: "email": "not-an-email"
Form validation errors, business logic violations, data format issues.
429 Too Many Requests User has sent too many requests in a given time period.
API rate limit: 100 requests per hour exceeded
API rate limiting, DDoS protection, spam prevention.
500 Internal Server Error Generic error when server fails unexpectedly.
Database connection failed, unhandled exception in code
Programming errors, database issues, server misconfigurations.
501 Not Implemented Server doesn't support the functionality required to fulfill the request.
HTTP method not implemented: PATCH requests not supported
Unsupported HTTP methods, missing features, incomplete API implementations.
502 Bad Gateway Invalid response received from upstream server.
Load balancer receives invalid response from backend server
Proxy server issues, microservice communication failures, CDN problems.
503 Service Unavailable Server is temporarily unable to handle requests.
Server maintenance, overloaded with requests
Scheduled maintenance, server overload, temporary outages.
504 Gateway Timeout Upstream server didn't respond within the timeout period.
API gateway timeout waiting for microservice response
Slow database queries, network issues, overloaded backend services.
507 Insufficient Storage Server cannot store the representation needed to complete the request.
File upload fails due to disk space limitations
Disk space issues, storage quota exceeded, large file uploads.