Skip to content
Errors & Status Code Semantics
step 1/5

Reading — step 1 of 5

Read

~1 min readProduction Features

Errors & Status Code Semantics

Every error condition maps to a specific status code. Picking the wrong one breaks client behavior:

CodeWhen
400Malformed request the client should fix
401Authentication required (with WWW-Authenticate header)
403Authenticated but not authorized
404Resource doesn't exist
405Method not allowed for this URL (must include Allow header)
408Client took too long sending the request
409Conflict (e.g., editing stale data)
413Body too large
414URI too long
415Unsupported Media Type (Content-Type your server can't parse)
429Too many requests (rate-limited)
500Generic server error (programmer's fault)
502Bad gateway (upstream server returned garbage)
503Service unavailable (overload, maintenance)
504Gateway timeout (upstream too slow)

Never use 500 as a default for client mistakes — it tells your client team "this is your problem to debug" instead of "I sent bad data."

Always include a body (even a brief plaintext explanation). Browsers, curl users, and ops engineers all read it.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…