Appropriate HTTP status code when authorization server is unavailable

We have authorization server which is in charge of checking token validity, expiration etc. Which HTTP status code should be returned if the authorization server is down?

Should it be 401 with “Authorization server down” message, error 500, or something else?


503 Service Unavailable

The 503 (Service Unavailable) status code indicates that the server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay. The server MAY send a Retry-After header field (Section 7.1.3) to suggest an appropriate amount of time for the client to wait before retrying the request.

503 is preferable to 4xx because it correctly communicates that the request itself was fine, that the problem resides on the server, and retrying the request at a later time should work.

503 is preferable to 500 because it does a better job expressing the fact that the condition is expected to be temporary (especially in the case where the origin server is able to provide Retry-After).

Prior art:


Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *