SiteError.comYour friendly guide to HTTP status codes
Status CodesBlog
  1. Home
  2. Compare
  3. 503 vs 502

503 vs 502

Service Unavailable vs Bad Gateway

πŸ”§503Service Unavailable
πŸŒ‰502Bad Gateway

Server Error Troubleshooting

Understanding the difference between 500, 502, and 503

πŸ’₯
500
Internal Error
Server Crash

Something broke!

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

πŸ“¨Request
Sent to server
↓
πŸ’₯Server crashes/errors
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.

πŸ‘€Client
Request sent
↓
πŸšͺGateway/Proxy
Forwards to upstream
↓
❌Upstream server fails
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.

πŸ“¨Request
Sent to server
↓
🚧Server busy/maintenance
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.

Β πŸ”§503πŸŒ‰502
NameService UnavailableBad Gateway
Category
5xxServer Error
5xxServer Error
DescriptionThe server is not ready to handle the request, often due to maintenance or overloading.The server was acting as a gateway and received an invalid response from the upstream server.
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
  • Proxy/gateway received invalid response from upstream server
  • Backend server returned malformed data or crashed mid-response
  • Use when your server is a proxy and upstream failed
Common Causes
  • Server maintenance
  • Server overloaded
  • Temporary outage
  • Upstream server is down
  • Proxy received invalid response
  • Backend server crashed
πŸ”§503Service Unavailable5xxServer Error
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
πŸŒ‰502Bad Gateway5xxServer Error
Description

The server was acting as a gateway and received an invalid response from the upstream server.

When to Use
  • Proxy/gateway received invalid response from upstream server
  • Backend server returned malformed data or crashed mid-response
  • Use when your server is a proxy and upstream failed
Common Causes
  • Upstream server is down
  • Proxy received invalid response
  • Backend server crashed

Popular Status Codes

  • 200 OK
  • 301 Moved Permanently
  • 302 Found
  • 400 Bad Request
  • 401 Unauthorized
  • 403 Forbidden
  • 404 Not Found
  • 500 Internal Server Error
  • 502 Bad Gateway
  • 503 Service Unavailable

Compare Codes

  • 401 vs 403
  • 301 vs 302
  • 404 vs 410
  • 500 vs 502
  • Compare any codes β†’

Categories

  • Informational
  • Success
  • Redirection
  • Client Error
  • Server Error
  • NGINX
  • Cloudflare
  • AWS ELB
  • Microsoft IIS

Tools

  • Cheat Sheet
  • Status Code Quiz
  • URL Checker
  • API Playground
  • Blog

Β© 2026 SiteError.com. All rights reserved.