When should an API return a 500 Internal Server Error versus a 503 Service Unavailable?

Last updated 29 June 2026

  • 500 Internal Server Error: an unexpected bug or unhandled exception. The client can't fix it and retrying usually won't help.

  • 503 Service Unavailable: a temporary condition (overload, deployment, maintenance, dependency outage). Pair it with a Retry-After header.

  • Rule of thumb: 500 = "something broke", 503 = "working fine, just not right now."

  • https://www.digitalapplied.com/blog/api-error-handling-resilience-2026-engineering-reference
  • https://dev.to/yorgie7/understanding-gateway-errors-500-502-503-504-an-expert-end-to-end-guide-for-developers-2dp1
All REST API interview questions