curl -s -o /dev/null -w '%{http_code}
' https://example.com/healthA compact pattern for extracting the final status code in shell scripts.
Common HTTP status code comparisons, cURL debugging recipes, and troubleshooting patterns.
Quick commands for checking status codes and redirects.
curl -s -o /dev/null -w '%{http_code}
' https://example.com/healthA compact pattern for extracting the final status code in shell scripts.
curl -s -o /dev/null -D - https://example.com | grep -i '^location:'Useful for checking 301, 302, 307, and 308 behavior.
curl -s -o /dev/null -w 'code=%{http_code} time=%{time_total}
' https://example.comHelpful when distinguishing slow 200s from outright 5xx failures.
curl -i -X POST https://example.com/api/users -H 'Content-Type: application/json' -d '{"name":"Ada"}'A good baseline for reproducing 400, 401, 403, 415, 422, and 429 responses.
Frequent status-code situations in web apps and APIs.
401 = not authenticated / invalid credentials
403 = authenticated but forbiddenA very common distinction in API and admin-console debugging. `401` often includes `WWW-Authenticate`; `403` is about permission refusal.
404 = not found
410 = gone permanentlyUse `410` when you want to communicate that the resource was intentionally removed and is not coming back.
301 = permanent
302 = temporary
307 = temporary, preserve method
308 = permanent, preserve method`307` and `308` are often better for APIs when method preservation matters.
502 = bad upstream response
503 = service unavailable / overloaded / maintenance
504 = upstream timeoutThese are some of the most common proxy and load-balancer errors.
304 Not Modified
412 Precondition FailedConditional requests with ETag or date validators often center around `304` and `412`.