Error codes & fixes: HTTP status codes & TLS
15 Error codes & fixes commands: HTTP status codes & TLS. Click a command to see what each part does.
HTTP status codes & TLS15
curl -sSIL <url>301 / 302Redirect: see every hopWhat it means
301 Moved Permanently / 302 Found: the resource is at another URL, given in the
Locationheader. Not an error by itself.Usual causes & fixes
- Redirect loop (ERR_TOO_MANY_REDIRECTS): HTTP→HTTPS redirect behind a load balancer that terminates TLS. The app sees HTTP every time; trust
X-Forwarded-Proto. - Wrong host or missing trailing slash in the
Locationheader. - Old path after a move: update the link or add a permanent redirect.
Diagnose: what each part of the command does
curlmake an HTTP request-s -Sno progress bar, but still show errors-Iheaders only (HEAD request)-Lfollow redirects, printing the headers of every hop<url>the address you are testing
- Redirect loop (ERR_TOO_MANY_REDIRECTS): HTTP→HTTPS redirect behind a load balancer that terminates TLS. The app sees HTTP every time; trust
curl -v -X POST -H "Content-Type: application/json" -d @<file>.json <url>400Bad Request: look at exactly what you sendWhat it means
The server will not process the request because of a client error: malformed syntax, invalid framing, bad parameters.
Usual causes & fixes
- Invalid JSON: check it with
jq . <file>.json. - Missing or wrong
Content-Typeheader. - Headers or cookies too large (nginx: "Request Header Or Cookie Too Large" → raise
large_client_header_buffers). - Required field missing: read the response body, APIs usually say which one.
Diagnose: what each part of the command does
-vverbose: print request and response headers-X POSTHTTP method-H "Content-Type: application/json"tell the server the body is JSON-d @<file>.jsonsend the body from a file (@ = read file)
- Invalid JSON: check it with
curl -i -H "Authorization: Bearer <token>" <url>401Unauthorized: test the credentialsWhat it means
"Unauthenticated": the request has no valid credentials. The
WWW-Authenticateresponse header says which scheme is expected.Usual causes & fixes
- Token missing, expired or for the wrong environment.
- Wrong scheme: Bearer vs Basic vs an API-key header.
- Clock skew makes a fresh JWT look expired/not-yet-valid: check
timedatectl. - A proxy (basic auth, oauth2-proxy) in front of the app asks for its own login.
Diagnose: what each part of the command does
-iinclude response headers in the output-H "Authorization: Bearer <token>"send the token the way the API expects
namei -l <path-to-file>403Forbidden: check the server log and the file pathWhat it means
The server knows who you are but refuses access.
Usual causes & fixes
- nginx/Apache: the web server user needs
xon every parent folder andron the file (see namei output). Checksudo tail -n 50 /var/log/nginx/error.log. - Folder requested but no index file and autoindex off → 403.
- IP allow/deny list, WAF rule, or a cloud bucket policy.
- Kubernetes API "forbidden": RBAC. Check with
kubectl auth can-i <verb> <resource> -n <namespace>.
Diagnose: what each part of the command does
nameifollow a path one component at a time-llong format: owner, group and permissions of EVERY directory on the way<path-to-file>e.g. /var/www/site/index.html
- nginx/Apache: the web server user needs
curl -sS -o /dev/null -w "%{http_code} %{url_effective}\n" -L <url>404Not Found: what does the server actually return?What it means
The server cannot find the requested resource. For an API it can also mean the endpoint exists but the object does not.
Usual causes & fixes
- Typo or wrong path/base path (e.g. app served under /api but called at /).
- nginx
location/root/aliaspoints somewhere else:nginx -T | grep -n -A5 "location". - Kubernetes ingress host or path does not match (see the next entry).
- Static site: file not deployed, or case-sensitive name (Index.html vs index.html).
Diagnose: what each part of the command does
-sSquiet, show errors-o /dev/nulldiscard the body-w "%{http_code} %{url_effective}\n"print the final status and the final URL after redirects-Lfollow redirects
kubectl get ingress -A; kubectl describe ingress <ingress> -n <namespace>404Not Found behind a Kubernetes ingressWhat it means
The ingress controller answered but no rule matched the host + path (often the controller's default 404 page).
Usual causes & fixes
- Host header does not match the
host:rule (test withcurl -H "Host: <host>" http://<ingress-ip>/<path>). pathType: ExactvsPrefix, or a rewrite annotation changing the path.- Wrong
ingressClassName, so a different controller (or none) owns the ingress.
Diagnose: what each part of the command does
get ingress -Aall ingresses with their HOSTS and ADDRESSdescribe ingress <ingress>rules: host + path → service:port, and events-n <namespace>namespace of the ingress
- Host header does not match the
curl -i -X OPTIONS <url>405Method Not Allowed: which methods are allowed?What it means
The method (GET/POST/PUT…) is known but not supported for this URL.
Usual causes & fixes
- POST to a static location, or GET to a POST-only endpoint.
- A proxy or ingress rule only allows some methods.
- CORS preflight (OPTIONS) not handled by the API.
Diagnose: what each part of the command does
-ishow response headers-X OPTIONSask the server which methods it supports (Allow header)
grep -rn "client_max_body_size" /etc/nginx/413Content Too Large: find the body size limitWhat it means
The request body is larger than the server allows.
Usual causes & fixes
- nginx: raise
client_max_body_size 50m;in the http/server/location block, thensudo nginx -t && sudo systemctl reload nginx. - ingress-nginx: annotation
nginx.ingress.kubernetes.io/proxy-body-size: "50m". - App or framework upload limit as well.
Diagnose: what each part of the command does
grep -rnsearch recursively with line numbers"client_max_body_size"nginx directive that limits upload size/etc/nginx/nginx config folder
- nginx: raise
curl -sI <url> | grep -i -E "retry-after|ratelimit"429Too Many Requests: read the rate-limit headersWhat it means
You sent too many requests in a given time (rate limiting).
Usual causes & fixes
- Wait for
Retry-Afterseconds; add backoff with jitter to clients. - Retry storm from many pods sharing one egress IP / API key.
- Docker Hub "toomanyrequests" on image pulls:
docker loginor use a mirror.
Diagnose: what each part of the command does
curl -sIquiet, headers only| grep -i -Ecase-insensitive, extended regex filter"retry-after|ratelimit"Retry-After and X-RateLimit-* headers
- Wait for
kubectl logs <pod> -n <namespace> --tail=100500Internal Server Error: read the application logsWhat it means
Generic "the server hit something it does not know how to handle": the app crashed or threw.
Usual causes & fixes
- Unhandled exception: the stack trace is in the app log (
docker logs <container>/journalctl -u <service>). - Bad config or missing env var after a deploy: compare with the previous version, roll back if needed.
- Downstream dependency (DB, cache) down or credentials rotated.
Diagnose: what each part of the command does
kubectl logs <pod>app output (stack traces end up here)-n <namespace>namespace--tail=100last 100 lines
- Unhandled exception: the stack trace is in the app log (
sudo tail -n 50 /var/log/nginx/error.log502Bad Gateway: the proxy got no valid answer from the appWhat it means
The gateway/proxy received an invalid response from the upstream (your app).
Usual causes & fixes
- App not running or crashed: check
systemctl status <service>/ pod status. - Proxy points to the wrong port (
proxy_pass/ ServicetargetPort). - App listens on 127.0.0.1 inside a container instead of 0.0.0.0.
- TLS mismatch: proxy speaks HTTP to an HTTPS backend or the reverse.
Diagnose: what each part of the command does
sudolog files are root-onlytail -n 50last 50 lines/var/log/nginx/error.lognginx error log: says why the upstream failed (connection refused, reset, …)
- App not running or crashed: check
kubectl get endpointslices -l kubernetes.io/service-name=<service> -n <namespace>502 / 503Kubernetes service has no ready pods behind itWhat it means
Empty ENDPOINTS = the Service has nowhere to send traffic, so the ingress returns 502/503.
Usual causes & fixes
- Service
selectordoes not match the pod labels: comparekubectl get svc <service> -o yamlwithkubectl get pods --show-labels. - Pods exist but are not Ready: readiness probe failing (
kubectl describe pod <pod>→ Events). targetPortdoes not match the containerPort.
Diagnose: what each part of the command does
get endpointslicesthe pod IPs a Service actually sends traffic to-l kubernetes.io/service-name=<service>only the slices of that Service-n <namespace>namespace
- Service
kubectl get pods -l app=<app> -n <namespace> -o wide503Service Unavailable: are the pods ready?What it means
The server is not ready to handle the request: down for maintenance or overloaded. Often sent with
Retry-After.Usual causes & fixes
- READY 0/1: readiness probe failing (wrong path/port, app still starting).
- All replicas restarting or scaled to 0.
- Maintenance mode or circuit breaker in the proxy/mesh (Envoy "no healthy upstream").
Diagnose: what each part of the command does
-l app=<app>pods of that app-o wideshow node and IP too
curl -sS -o /dev/null -w "connect=%{time_connect}s ttfb=%{time_starttransfer}s total=%{time_total}s\n" <url>504Gateway Timeout: how long does the backend take?What it means
The gateway did not get a response from the upstream in time.
Usual causes & fixes
- Backend slower than the proxy timeout: nginx
proxy_read_timeoutdefaults to 60s; cloud load balancers have their own idle timeout. - Slow DB query or external call: check app/DB logs.
- Network path blocked (security group / firewall) so the connect hangs.
Diagnose: what each part of the command does
-o /dev/nulldiscard body%{time_connect}time to open the TCP connection%{time_starttransfer}time to first byte: how long the backend "thought"%{time_total}whole request
- Backend slower than the proxy timeout: nginx
echo | openssl s_client -connect <host>:443 -servername <host> 2>/dev/null | openssl x509 -noout -subject -issuer -datesTLSCertificate expired / not trusted: inspect the certWhat it means
Errors like "certificate has expired", "unable to get local issuer certificate" or "hostname mismatch" come from the certificate the server presents.
Usual causes & fixes
- Expired: renew (cert-manager / certbot) and reload the server.
- Missing intermediate chain: serve the full chain (fullchain.pem).
- Hostname not in the SAN list, or wrong SNI/default certificate.
Diagnose: what each part of the command does
echo |send an empty request so s_client exitsopenssl s_client -connect <host>:443do a TLS handshake-servername <host>SNI: ask for the certificate of this host name2>/dev/nullhide handshake noiseopenssl x509 -nooutparse the certificate, do not print it-subject -issuer -dateswho it is for, who signed it, valid from / until
Nothing matches.
My DevOps Playbook by Angelo John Calleja