HTTP

HTTP 500 Internal Server Error vs 503 Service Unavailable

Both 500 and 503 signal server failures, but 503 specifically indicates a temporary condition. A 500 is a generic catch-all for unexpected errors, while a 503 tells clients the service is temporarily unavailable and they should retry later.

Описание

The server encountered an unexpected condition that prevented it from fulfilling the request. A generic catch-all for server-side errors.

Когда вы это видите

When an unhandled exception occurs, a database connection fails, or server code has a bug.

Как исправить

Check server logs for the stack trace. Common causes: unhandled exceptions, database errors, misconfigurations.

Описание

The server is temporarily unable to handle the request due to maintenance or overload. Should include a Retry-After header.

Когда вы это видите

During maintenance windows, server overload, or when the application pool is exhausted.

Как исправить

Wait and retry. Check the Retry-After header. Scale up servers if it's a capacity issue.

Ключевые различия

1.

500 is a generic server error with no guarantee of recovery — it may be a bug, a crash, or a permanent issue.

2.

503 explicitly signals a temporary condition — the server expects to recover (maintenance, overload, rate limiting).

3.

503 should include a Retry-After header to tell clients when to try again.

4.

500 suggests a developer needs to investigate and fix a bug; 503 suggests waiting is the correct response.

5.

Load balancers and CDNs may handle 503 specially, routing traffic to healthy instances or serving cached content.

Когда что использовать

Return 500 for unexpected errors like unhandled exceptions, corrupted state, or programming bugs. Return 503 when the server is intentionally unavailable: during scheduled maintenance, when a dependency is down, or when capacity limits are reached. Always include a Retry-After header with 503.

Узнать больше