Skip to content

500 vs 503

Internal Server Error vs Service Unavailable

500Internal Server Error

Oops, we broke it! The server had a little meltdown. It's not you, it's definitely us.

HTTP Response
HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{"error": "Something went wrong"}

503Service Unavailable

BRB! The server is taking a coffee break or being pampered with maintenance. Please hold!

HTTP Response
HTTP/1.1 503 Service Unavailable
Retry-After: 3600
πŸ’₯500Internal Server Error
πŸ”§503Service Unavailable

Server Error Troubleshooting

500
Internal Error
πŸ’₯

Server Crash

Something broke!

The server encountered an unexpected condition that prevented it from fulfilling the request.

  1. Request
  2. Sent to server
    Server crashes/errors
  3. Unhandled exception
    500 Error
Common causes:
  • Unhandled exceptions in code
  • Database connection failures
  • Misconfigured server settings
502
Bad Gateway
πŸ”Œ

Upstream Failure

Can't reach backend!

The gateway or proxy received an invalid response from the upstream server it tried to access.

  1. Client
  2. Request sent
    Gateway/Proxy
  3. Forwards to upstream
    Upstream server fails
  4. Invalid/no response
    502 Error
Common causes:
  • Upstream server is down
  • Network connectivity issues
  • Backend timeout or crash
503
Unavailable
🚧

Temporary Outage

Try again later!

The server is temporarily unable to handle requests due to maintenance or overload.

  1. Request
  2. Sent to server
    Server busy/maintenance
  3. Cannot process now
    503 Error
Common causes:
  • Scheduled maintenance
  • Server overload/too many requests
  • Resource exhaustion

Quick Decision Guide

Use 500 when:
  • Application code throws an exception
  • Database query fails unexpectedly
  • Critical configuration is missing
  • Generic error with no specific cause
Use 502 when:
  • Reverse proxy can't reach backend
  • Load balancer gets invalid response
  • API gateway connection fails
  • Upstream server returns malformed data
Use 503 when:
  • Server is in maintenance mode
  • Too many concurrent connections
  • Rate limit temporarily exceeded
  • Include Retry-After header
πŸ’‘

Key Insight

500 means the server itself has a problem. 502 means the server is working but can't connect to its backend. 503 means the server is working but deliberately refusing requests. If you're using a reverse proxy (nginx, load balancer), you'll likely see 502. If your app code crashes, that's a 500. If you're deploying or overwhelmed with traffic, send 503.

Description

The server has encountered a situation it doesn't know how to handle.

When to Use
  • Unexpected server error with no more specific 5xx code applicable
  • Unhandled exceptions or crashes in your application
  • Generic catch-all for server-side failures
Common Causes
  • Unhandled exception in code
  • Database connection failed
  • Server misconfiguration
Description

The server is not ready to handle the request, often due to maintenance or overloading.

When to Use
  • Server is temporarily overloaded and can't handle requests
  • Planned maintenance window
  • Include Retry-After header to indicate when to try again
Common Causes
  • Server maintenance
  • Server overloaded
  • Temporary outage