HTTP to gRPC Status Code Mapping

Since intermediaries are a common part of HTTP infrastructure some responses to gRPC requests may be received that do not include the grpc-status header. In some cases mapping error codes from an intermediary allows the gRPC client to behave more appropriately to the error situation without overloading the semantics of either error code.

This table is to be used only for clients that received a response that did not include grpc-status. If grpc-status was provided, it must be used. Servers must not use this table to determine an HTTP status code to use; the mappings are neither symmetric nor 1-to-1.

HTTP Status CodegRPC Status Code
400 Bad RequestINTERNAL
401 UnauthorizedUNAUTHENTICATED
403 ForbiddenPERMISSION_DENIED
404 Not FoundUNIMPLEMENTED
429 Too Many RequestsUNAVAILABLE
502 Bad GatewayUNAVAILABLE
503 Service UnavailableUNAVAILABLE
504 Gateway TimeoutUNAVAILABLE
All other codesUNKNOWN

Technically, 1xx should have the entire header skipped and a subsequent header be read. See RFC 7540 ยง8.1.

200 is UNKNOWN because there should be a grpc-status in case of truly OK response.