interview-prep

You did something wrong. These are your problem to fix and should trigger alerts.

500 Internal Server Error

Meaning: Generic server error — the application threw an unhandled exception. What to check (in order):

  1. Application logs — the stack trace is in there
  2. Recent deployment — did something ship in the last hour?
  3. Downstream dependencies — database connection, downstream API, cache
  4. Resource exhaustion — out of memory (OOMKilled in K8s), thread pool exhausted, file handles
  5. Config issue — environment variable missing, secret rotated incorrectly

Common 500 root causes:

  • Null pointer / undefined reference
  • Unhandled exception in a code path that wasn't tested
  • Database query timing out
  • External API returning unexpected response that the code can't handle
  • Config typo in the latest deploy
501 Not Implemented

Meaning: Server doesn't recognise the HTTP method. What to check: Rare in modern systems. Usually indicates a proxy or framework misconfiguration.

502 Bad Gateway

Meaning: The reverse proxy / load balancer got an invalid response from upstream. What to check:

  • Upstream is down or crashed — target group shows unhealthy
  • Upstream returned a malformed response (cut connection mid-response)
  • Upstream timed out before responding
  • Application restarted during request handling
  • Container OOMKilled mid-request

502 troubleshooting flow:

  1. Check load balancer / Ingress target health
  2. Check upstream pod/instance status (running, healthy)
  3. Check upstream logs for crashes or panics
  4. Check kubectl describe pod for OOMKilled or restart loops
  5. Check resource limits — is the container hitting memory cap?

502 is the most common cause of "site went down for 5 minutes." Almost always upstream health.

503 Service Unavailable

Meaning: Server is temporarily unable to handle the request. Either overloaded or in maintenance. What to check:

  • No healthy upstream targets — ALB shows 0/N healthy
  • Autoscaling can't keep up with traffic spike
  • Maintenance mode flag still on after a deployment
  • Circuit breaker open — application self-protecting from cascading failure
  • Database connection pool exhausted

503 vs 502: 503 usually means the server knows it can't serve (overloaded, in maintenance). 502 means the proxy tried but got nothing useful back.

504 Gateway Timeout

Meaning: Reverse proxy waited for upstream and gave up. What to check:

  • Upstream is slow but not failed
  • Database query running long
  • Downstream API call hanging
  • Long-running synchronous work that should be async
  • Load balancer timeout shorter than expected response time (common gotcha — ALB default is 60s)

504 troubleshooting flow:

  1. Compare load balancer timeout to typical upstream response time
  2. Check upstream APM / traces for slow operations
  3. Check database for long-running queries (pg_stat_activity in Postgres, SHOW PROCESSLIST in MySQL)
  4. Check thread pool / worker saturation in the application
  5. Check downstream service health and latency
505 HTTP Version Not Supported

Meaning: Server doesn't support the HTTP version in the request. What to check: Almost always a client/proxy misconfiguration. Rare.

My notes