Skip to content

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.

Index
15 items
Click a command to see what each part does.

HTTP status codes & TLS15

  • curl -sSIL <url>301 / 302Redirect: see every hop

    What it means

    301 Moved Permanently / 302 Found: the resource is at another URL, given in the Location header. 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 Location header.
    • Old path after a move: update the link or add a permanent redirect.

    Diagnose: what each part of the command does

    1. curlmake an HTTP request
    2. -s -Sno progress bar, but still show errors
    3. -Iheaders only (HEAD request)
    4. -Lfollow redirects, printing the headers of every hop
    5. <url>the address you are testing
  • curl -v -X POST -H "Content-Type: application/json" -d @<file>.json <url>400Bad Request: look at exactly what you send

    What 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-Type header.
    • 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

    1. -vverbose: print request and response headers
    2. -X POSTHTTP method
    3. -H "Content-Type: application/json"tell the server the body is JSON
    4. -d @<file>.jsonsend the body from a file (@ = read file)
  • curl -i -H "Authorization: Bearer <token>" <url>401Unauthorized: test the credentials

    What it means

    "Unauthenticated": the request has no valid credentials. The WWW-Authenticate response 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

    1. -iinclude response headers in the output
    2. -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 path

    What it means

    The server knows who you are but refuses access.

    Usual causes & fixes

    • nginx/Apache: the web server user needs x on every parent folder and r on the file (see namei output). Check sudo 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

    1. nameifollow a path one component at a time
    2. -llong format: owner, group and permissions of EVERY directory on the way
    3. <path-to-file>e.g. /var/www/site/index.html
  • 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 / alias points 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

    1. -sSquiet, show errors
    2. -o /dev/nulldiscard the body
    3. -w "%{http_code} %{url_effective}\n"print the final status and the final URL after redirects
    4. -Lfollow redirects
  • kubectl get ingress -A; kubectl describe ingress <ingress> -n <namespace>404Not Found behind a Kubernetes ingress

    What 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 with curl -H "Host: <host>" http://<ingress-ip>/<path>).
    • pathType: Exact vs Prefix, 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

    1. get ingress -Aall ingresses with their HOSTS and ADDRESS
    2. describe ingress <ingress>rules: host + path → service:port, and events
    3. -n <namespace>namespace of the ingress
  • 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

    1. -ishow response headers
    2. -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 limit

    What 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, then sudo 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

    1. grep -rnsearch recursively with line numbers
    2. "client_max_body_size"nginx directive that limits upload size
    3. /etc/nginx/nginx config folder
  • curl -sI <url> | grep -i -E "retry-after|ratelimit"429Too Many Requests: read the rate-limit headers

    What it means

    You sent too many requests in a given time (rate limiting).

    Usual causes & fixes

    • Wait for Retry-After seconds; add backoff with jitter to clients.
    • Retry storm from many pods sharing one egress IP / API key.
    • Docker Hub "toomanyrequests" on image pulls: docker login or use a mirror.

    Diagnose: what each part of the command does

    1. curl -sIquiet, headers only
    2. | grep -i -Ecase-insensitive, extended regex filter
    3. "retry-after|ratelimit"Retry-After and X-RateLimit-* headers
  • kubectl logs <pod> -n <namespace> --tail=100500Internal Server Error: read the application logs

    What 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

    1. kubectl logs <pod>app output (stack traces end up here)
    2. -n <namespace>namespace
    3. --tail=100last 100 lines
  • sudo tail -n 50 /var/log/nginx/error.log502Bad Gateway: the proxy got no valid answer from the app

    What 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 / Service targetPort).
    • 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

    1. sudolog files are root-only
    2. tail -n 50last 50 lines
    3. /var/log/nginx/error.lognginx error log: says why the upstream failed (connection refused, reset, …)
  • kubectl get endpointslices -l kubernetes.io/service-name=<service> -n <namespace>502 / 503Kubernetes service has no ready pods behind it

    What it means

    Empty ENDPOINTS = the Service has nowhere to send traffic, so the ingress returns 502/503.

    Usual causes & fixes

    • Service selector does not match the pod labels: compare kubectl get svc <service> -o yaml with kubectl get pods --show-labels.
    • Pods exist but are not Ready: readiness probe failing (kubectl describe pod <pod> → Events).
    • targetPort does not match the containerPort.

    Diagnose: what each part of the command does

    1. get endpointslicesthe pod IPs a Service actually sends traffic to
    2. -l kubernetes.io/service-name=<service>only the slices of that Service
    3. -n <namespace>namespace
  • 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

    1. -l app=<app>pods of that app
    2. -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_timeout defaults 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

    1. -o /dev/nulldiscard body
    2. %{time_connect}time to open the TCP connection
    3. %{time_starttransfer}time to first byte: how long the backend "thought"
    4. %{time_total}whole request
  • echo | openssl s_client -connect <host>:443 -servername <host> 2>/dev/null | openssl x509 -noout -subject -issuer -datesTLSCertificate expired / not trusted: inspect the cert

    What 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

    1. echo |send an empty request so s_client exits
    2. openssl s_client -connect <host>:443do a TLS handshake
    3. -servername <host>SNI: ask for the certificate of this host name
    4. 2>/dev/nullhide handshake noise
    5. openssl x509 -nooutparse the certificate, do not print it
    6. -subject -issuer -dateswho it is for, who signed it, valid from / until

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…