Skip to content
gohacks.dev
APIs

gRPC Status Codes

All 17 gRPC status codes from OK to UNAUTHENTICATED with their numbers, the HTTP status they map to, what each means and when a client should retry.

Free · No sign-up · Your inputs stay in your browser

Reference

gRPC status codes

CodeNameHTTPMeaning
0OK200Success.
1CANCELLED499The caller cancelled, usually a client timeout or a closed connection.
2UNKNOWN500An error with no better code; often an unhandled exception.
3INVALID_ARGUMENT400The request is wrong regardless of server state. Do not retry.
4DEADLINE_EXCEEDED504The deadline passed; the operation may still have completed.
5NOT_FOUND404
6ALREADY_EXISTS409
7PERMISSION_DENIED403Authenticated but not allowed.
8RESOURCE_EXHAUSTED429Quota or rate limit, or out of memory. Retry with backoff.
9FAILED_PRECONDITION400The system is not in a state for this (a directory not empty). Fix state, then retry.
10ABORTED409Concurrency conflict such as a transaction abort; retry the whole sequence.
11OUT_OF_RANGE400Past the valid range, such as reading beyond end of file.
12UNIMPLEMENTED501Method not implemented or not enabled.
13INTERNAL500An invariant broke: a serious server-side bug.
14UNAVAILABLE503Transient; the one code that is generally safe to retry with backoff.
15DATA_LOSS500Unrecoverable data loss or corruption.
16UNAUTHENTICATED401No valid credentials.

From grpc/doc/statuscodes.md; the HTTP column is the mapping gRPC-Gateway and Google's API design guide use. Choose FAILED_PRECONDITION versus ABORTED versus UNAVAILABLE by what the client should do next: fix state, retry the sequence, or retry the call.

Choosing the right code

The gRPC documentation's rule of thumb: use UNAVAILABLE if the client can retry just the failing call, ABORTED if it should retry at a higher level such as restarting a transaction, and FAILED_PRECONDITION if it should not retry until the system state is fixed. The codes are defined in gRPC's status codes guide.

Errors from the transport

Some codes are produced by the gRPC library rather than your handler: DEADLINE_EXCEEDED when a deadline passes, UNAVAILABLE when a connection fails, CANCELLED when the client goes away.

Share

Frequently asked questions

What HTTP status does gRPC NOT_FOUND map to?
404. INVALID_ARGUMENT maps to 400, PERMISSION_DENIED to 403 and UNAVAILABLE to 503.
Is it safe to retry DEADLINE_EXCEEDED?
Only for idempotent calls: the server may have completed the work after the client stopped waiting.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools