HTTP Error Codes — 4xx Client Errors & 5xx Server Errors
All 34 status codes · Search · Filter · Snippets · cURL Tester · Favorites
Complete reference for HTTP error codes. 4xx codes indicate client errors — the request was wrong. 5xx codes indicate server errors — the server failed. Includes code snippets for handling errors in JavaScript, Express.js, Python Flask, and nginx. Use the filter tab to see only 4xx or 5xx codes.
Click any status code to see full details, code snippets, and usage guide
Frequently Asked Questions
What is the most common HTTP error code?
404 Not Found is the most famous HTTP error code, seen by virtually every internet user. In APIs, 400 Bad Request and 401 Unauthorized are the most common errors developers encounter. 500 Internal Server Error is the most feared — it means something unexpected went wrong on the server.
Should my API return 500 for database errors?
Yes — when an unexpected database error occurs that you cannot specifically categorize, 500 is appropriate. However, for known error conditions (database unique constraint violation = 409 Conflict, record not found = 404), use the specific code. Never expose raw database error messages in production API responses — log them server-side and return a generic message.
What is 429 Too Many Requests and how do I implement it?
429 is returned when a client exceeds your rate limit. Implement with a rate limiter middleware (express-rate-limit for Node.js, flask-limiter for Python). Include Retry-After: 60 header to tell clients when to retry. Add X-RateLimit-Limit: 100 (max requests), X-RateLimit-Remaining: 0 (remaining), X-RateLimit-Reset: 1699999999 (reset timestamp) headers.
When should I return 410 Gone vs 404 Not Found?
410 Gone explicitly tells the client (and search crawlers) that the resource existed and was permanently deleted. 404 is ambiguous — it may mean the resource never existed, was deleted, or the URL is wrong. Use 410 for intentionally deleted content to help search engines remove it from their index. Googlebot treats 410 as a stronger signal to deindex the URL than 404.
What does nginx error 502 Bad Gateway mean?
502 means nginx (acting as reverse proxy) received an invalid or empty response from the upstream server (your app). Common causes: app crashed and restart hasn't completed, app is taking too long to start, wrong proxy_pass port in nginx config, app is listening on wrong network interface (use 0.0.0.0 not 127.0.0.1 in Docker).
What is the difference between 503 and 504?
503 Service Unavailable means the server cannot handle the request right now — it's overloaded or down for maintenance. The server itself is responding (it sent the 503). 504 Gateway Timeout means the proxy/gateway made a request to an upstream server and it did not respond within the timeout period. 503 = server can't handle it now. 504 = upstream did not respond in time.