Complete HTTP Status Codes Directory
The definitive reference for all HTTP response status codes: meanings, troubleshooting steps, and ready-to-paste Apache & Nginx server fixes.
Continue
Description: The server has received the request headers and the client should proceed to send the request body.
Common Root Cause: Occurs when a client sends an `Expect: 100-continue` header before sending large payloads.
# Usually handled automatically by Apache for POST/PUT requests
client_body_buffer_size 128k;
client_max_body_size 50m;
Switching Protocols
Description: The requester has asked the server to switch protocols and the server has agreed to do so (e.g. Upgrade to WebSockets).
Common Root Cause: WebSocket handshake initiation (`Upgrade: websocket`).
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:3000/$1" [P,L]
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
OK
Description: Standard response for successful HTTP requests. The payload depends on the request method used.
Common Root Cause: The requested resource was located, executed, and returned without errors.
# Response 200 is default when resources exist
# Default success response code
Created
Description: The request has been fulfilled, resulting in the creation of a new resource.
Common Root Cause: Returned by REST APIs after successful `POST` operations that create records.
# Send header from application: header("HTTP/1.1 201 Created");
# Handled by backend application logic
No Content
Description: The server successfully processed the request and is not returning any content (useful for DELETE/OPTIONS).
Common Root Cause: Successful update/delete where the client does not need to navigate away from the current page.
# Handled by API route logic
# Return 204 for CORS preflight options:
if ($request_method = "OPTIONS") { return 204; }
Moved Permanently
Description: The requested resource has been assigned a new permanent URI. Search engines pass 90-99% link equity.
Common Root Cause: Domain migrations, HTTPS enforcement, non-www to www consolidation, or URL restructurings.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
Found (Temporary Redirect)
Description: The requested resource resides temporarily under a different URI. Search engines retain the original URL.
Common Root Cause: Short-term maintenance, geo-targeting redirection, or A/B testing variations.
Redirect 302 /old-page /temporary-promo
rewrite ^/sale$ /black-friday-deals redirect;
Not Modified
Description: Indicates that the resource has not been modified since the version specified by the request headers (ETag / If-Modified-Since).
Common Root Cause: Browser cache revalidation matches the server version; saves bandwidth by transmitting zero body payload.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
</IfModule>
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
Temporary Redirect (Method Preserved)
Description: The request should be repeated with another URI, but future requests should still use the original URI without changing the HTTP method (POST remains POST).
Common Root Cause: Modern replacement for 302 to guarantee the HTTP method and request body are preserved.
Redirect 307 /api/v1/checkout /api/v2/checkout
return 307 https://secure.example.com$request_uri;
Permanent Redirect (Method Preserved)
Description: The target resource has been assigned a new permanent URI and any future references MUST use that URI while preserving the request method.
Common Root Cause: Permanent API migration where POST/PUT bodies must not be converted into GET requests.
Redirect 308 /api/legacy /api/v3
return 308 https://api.example.com$request_uri;
Bad Request
Description: The server cannot or will not process the request due to an apparent client error (e.g. malformed syntax, invalid framing).
Common Root Cause: Malformed JSON payload, invalid request parameters, expired cookies, or missing mandatory headers.
LimitRequestFieldSize 16384
LimitRequestBody 10485760
large_client_header_buffers 4 16k;
client_header_buffer_size 4k;
Unauthorized
Description: The request has not been applied because it lacks valid authentication credentials for the target resource.
Common Root Cause: Missing or expired Bearer JWT token, invalid API key, or missing Basic Auth credentials.
AuthType Basic
AuthName "Restricted Area"
AuthUserFile /path/to/.htpasswd
Require valid-user
auth_basic "Admin Area";
auth_basic_user_file /etc/nginx/.htpasswd;
Forbidden
Description: The server understood the request, but refuses to authorize it. Unlike 401, re-authenticating makes no difference.
Common Root Cause: Incorrect file/directory permissions (e.g. 000 instead of 644/755), IP blocklist, or missing index.html.
# Fix permissions via SSH:
chmod 755 -R /var/www/html/ && chmod 644 /var/www/html/*.*
# In .htaccess:
Require all granted
# Ensure worker user has read permissions:
chown -R www-data:www-data /var/www/html
# Enable autoindex if no index file exists:
autoindex off;
Not Found
Description: The server can not find the requested resource. Links that lead to a 404 are often called broken or dead links.
Common Root Cause: Typo in URL, deleted file, missing rewrite rules for single-page applications (SPAs), or missing .htaccess.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
location / {
try_files $uri $uri/ /index.html;
}
Method Not Allowed
Description: The request method is recognized by the server but is not supported by the target resource (e.g. POST to a static file).
Common Root Cause: Sending a POST or PUT request to a static HTML endpoint or an API endpoint configured only for GET.
<LimitExcept GET POST HEAD>
deny from all
</LimitExcept>
error_page 405 =200 $uri;
Request Timeout
Description: The server timed out waiting for the request from the client. The client did not produce a request within the server timeout window.
Common Root Cause: Slow mobile network, large file upload interruption, or stalled connection.
TimeOut 300
KeepAliveTimeout 5
client_header_timeout 60s;
client_body_timeout 60s;
send_timeout 60s;
Too Many Requests (Rate Limited)
Description: The user has sent too many requests in a given amount of time (Rate Limiting).
Common Root Cause: API rate limits exceeded, scraping bots hitting the endpoint, or DDoS protection triggers.
<IfModule mod_ratelimit.c>
SetOutputFilter RATE_LIMIT
SetEnv rate-limit 500
</IfModule>
limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/s;
location /api/ {
limit_req zone=api_limit burst=20 nodelay;
}
Internal Server Error
Description: The server encountered an unexpected condition that prevented it from fulfilling the request.
Common Root Cause: Syntax error in code, corrupted .htaccess file, exhausted PHP memory limit, or database connection crash.
# Check Apache error logs:
tail -n 50 /var/log/apache2/error.log
# In php.ini increase memory:
memory_limit = 256M
# Check PHP-FPM error logs:
tail -n 50 /var/log/php8.2-fpm.log
# In php-fpm pool config:
pm.max_children = 50
Bad Gateway
Description: The server, while acting as a gateway or proxy, received an invalid response from the inbound server it accessed.
Common Root Cause: PHP-FPM or Node.js process crashed, upstream microservice timed out, or firewall blocked the upstream port.
# Restart PHP-FPM service:
systemctl restart php8.2-fpm
# Verify upstream is running and listening on correct socket/port:
upstream backend {
server unix:/run/php/php8.2-fpm.sock;
}
proxy_buffer_size 128k;
proxy_buffers 4 256k;
Service Unavailable
Description: The server is currently unable to handle the request due to temporary overloading or maintenance of the server.
Common Root Cause: Server CPU/RAM maxed out, scheduled maintenance mode enabled, or Cloudflare upstream capacity exceeded.
# Return 503 during maintenance:
RewriteEngine On
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteRule .* /maintenance.html [R=503,L]
error_page 503 /maintenance.html;
location = /maintenance.html {
root /var/www/html;
}
Gateway Timeout
Description: The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server or CDN.
Common Root Cause: Long-running database query, unoptimized loop in backend script, or Cloudflare timing out after 100 seconds.
ProxyTimeout 300
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
fastcgi_read_timeout 300s;