π₯ Complete HTTP Status Code Guide (DevOps Version)¶
π’ 1xx β Informational (Rarely Used in Debugging)¶
| Code | Meaning | DevOps Note |
|---|---|---|
| 100 | Continue | Client can send body |
| 101 | Switching Protocols | WebSocket upgrade |
Usually not part of troubleshooting.
π’ 2xx β Success Codes¶
These mean the server handled the request correctly.
| Code | Meaning | When You See It |
|---|---|---|
| 200 | OK | Normal website/API response |
| 201 | Created | Resource created (POST) |
| 202 | Accepted | Async job started |
| 204 | No Content | Health checks / DELETE |
π DevOps Tip:¶
If load balancer health check expects 200 but app returns 204 β can cause unhealthy status.
π‘ 3xx β Redirection (Infrastructure-Level Important)¶
| Code | Meaning | DevOps Usage |
|---|---|---|
| 301 | Permanent Redirect | Domain migration |
| 302 | Temporary Redirect | Short testing |
| 307 | Temporary (strict method) | API-safe redirect |
| 308 | Permanent (strict method) | Modern 301 |
π₯ 301 vs 302 Difference (Very Important)¶
| 301 | 302 |
|---|---|
| Browser caches permanently | Browser may not cache |
| SEO transfers authority | No SEO transfer |
| Used in domain migration | Used in temporary switch |
π΄ 4xx β Client Errors (VERY COMMON)¶
These happen because of request issues.
πΉ 400 β Bad Request¶
Malformed request.
Causes:
- Invalid JSON
- Wrong headers
- Corrupt cookies
πΉ 401 β Unauthorized¶
Authentication required.
Cause:
- Missing token
- Expired JWT
- Wrong API key
πΉ 403 β Forbidden¶
Server understood request but refuses.
Common DevOps Causes:
- Cloudflare WAF block
- Security group restriction
- Nginx deny rule
- IP blocked
πΉ 404 β Not Found¶
Resource doesnβt exist.
Causes:
- Wrong route
- Deployment missing files
- Wrong ingress path (Kubernetes)
πΉ 405 β Method Not Allowed¶
Wrong HTTP method used.
Example: POST on GET-only route.
πΉ 408 β Request Timeout¶
Client too slow.
πΉ 409 β Conflict¶
Data conflict (DB level).
πΉ 413 β Payload Too Large¶
Upload exceeded limit.
Often caused by:
- Nginx
client_max_body_size - Cloudflare upload limit
πΉ 429 β Too Many Requests¶
Rate limiting.
Caused by:
- API gateway limit
- Cloudflare rate limiting
- WAF rule
π₯ 5xx β Server Errors (Critical)¶
These are backend/server/infrastructure problems.
πΉ 500 β Internal Server Error¶
Application crashed.
Check:
- App logs
- Stack trace
- Runtime error
πΉ 501 β Not Implemented¶
Feature not supported.
πΉ 502 β Bad Gateway (VERY COMMON)¶
Gateway received invalid response from backend.
Common Causes:
- Backend down
- Wrong upstream IP
- Docker container crashed
- Wrong port mapping
- Load balancer target unhealthy
DevOps golden rule:
502 = Upstream problem
πΉ 503 β Service Unavailable¶
Server overloaded or down.
Causes:
- Auto-scaling delay
- Too much traffic
- Maintenance mode
πΉ 504 β Gateway Timeout (VERY IMPORTANT)¶
Gateway waited too long.
Causes:
- Slow DB
- Slow backend API
- Long-running query
- Timeout mismatch (Nginx vs app)
DevOps rule:
504 = Performance problem
π₯ Cloudflare-Specific Errors (Important for You)¶
| Code | Meaning |
|---|---|
| 520 | Unknown error |
| 521 | Web server down |
| 522 | Connection timed out |
| 523 | Origin unreachable |
| 525 | SSL handshake failed |
| 526 | Invalid SSL certificate |
Example: 522 β Your server not responding 525 β SSL mode mismatch
π§ DevOps Debug Flow Based on Status Code¶
If 4xx:¶
- Check request
- Check auth
- Check WAF
If 5xx:¶
- Check backend
- Check logs
- Check container status
- Check health checks
- Check timeouts
π₯ Real Interview Question¶
If interviewer asks:
What is difference between 502 and 504?
Correct Answer:
- 502 β Bad response from upstream
- 504 β No response within timeout
β‘ Quick Cheat Sheet¶
| Code | Check This |
|---|---|
| 401 | Auth |
| 403 | Firewall/WAF |
| 404 | Route/Ingress |
| 429 | Rate limit |
| 500 | App logs |
| 502 | Backend down |
| 503 | Overload |
| 504 | Slow backend |