How to troubleshoot HTTP error codes

· Category: Networking

Short answer

HTTP error codes indicate the result of a request. Codes are grouped into 1xx informational, 2xx success, 3xx redirects, 4xx client errors, and 5xx server errors.

Steps

  1. Identify the code: Read the exact status code returned by the server.

  2. Check client-side issues (4xx): - 400 Bad Request: Verify request syntax and payload. - 401 Unauthorized: Check authentication credentials. - 403 Forbidden: Review permissions and access controls. - 404 Not Found: Confirm the URL and file existence.

  3. Check server-side issues (5xx): - 500 Internal Server Error: Review application logs. - 502 Bad Gateway: Verify upstream service health. - 503 Service Unavailable: Check server load and maintenance windows.

  4. Inspect logs: Use server and application logs to find stack traces or detailed error messages.

  5. Reproduce consistently: Isolate the exact request causing the failure.

Tips

  • Use browser developer tools to inspect the full request and response.
  • Test with curl to eliminate browser-specific behavior.
  • Monitor error rates to catch systemic issues early.

Common issues

  • Misconfigured reverse proxies returning 502 errors.
  • Missing CORS headers causing misleading errors.
  • Rate limiting returning 429 Too Many Requests.