Preface / Hook
2 a.m., the deploy dashboard is solid red, three rollbacks and still 502. The logs show one line: upstream timeout. Nobody knows which layer broke — CDN, gateway, or origin. The core argument: an HTTP status code is the server's contract receipt, not decoration. One 301 that isn't followed to the end, one 200 that is really a soft 404, and a routine release becomes an incident. This piece covers 5 dimensions and 3 tools you can use today to turn "glance at the status code" into a repeatable triage flow.
1. Source control: don't let bad status codes reach production
1.1 Assert status before you ship
Turning "the homepage and key endpoints must return 200" into a pipeline assertion beats clicking through by hand.
// ❌ Wrong: only checking the build
npm run build && deploy
// ✅ Right: assert key routes after deploy
for path in / /pricing /api/health; do
code=$(curl -s -o /dev/null -w "%{http_code}" https://example.com$path)
[ "$code" = "200" ] || { echo "❌ $path -> $code"; exit 1; }
done
Toolchain:
- Dev: browser DevTools Network panel — read the Status column
- CI/CD:
curl -w "%{http_code}"ornewman; block merge on non-2xx - Runtime: gateway health probe
/healthzmust return 200
1.2 Tell a real 200 from a soft 404
Many SPAs return 200 + an empty page for unknown routes. Search engines read that as a soft 404 and dilute your crawl budget.
// Soft 404 signature: 200 but empty/error body
GET /no-such-page -> 200 (body: "Not Found")
// Correct: return a real 404
GET /no-such-page -> 404
Watch out: static sites need a real 404.html served with a 404; APIs should return 404, not 200 with an error field.
2. Toolchain: from manual curl to scheduled sweeps
2.1 Local dev: one curl line
# status only
curl -s -o /dev/null -w "%{http_code}\n" https://example.com
# status + redirect chain + timing
curl -sIL -w "final:%{http_code} time:%{time_total}s\n" https://example.com
2.2 CLI batch
# check a list, print status
cat urls.txt | while read u; do
echo "$(curl -s -o /dev/null -w '%{http_code}' "$u") $u"
done
# only non-2xx
cat urls.txt | while read u; do
c=$(curl -s -o /dev/null -w '%{http_code}' "$u")
[ "${c:0:1}" = "2" ] || echo "$c $u"
done
Big lists (1000+): use xargs -P for concurrency instead of serial checks.
# 20-way concurrent check
cat urls.txt | xargs -P20 -I{} sh -c 'echo "$(curl -s -o /dev/null -w "%{http_code}" "{}") {}"'
# or use the on-site batch tool
# 👉 HTTP Status Batch Checker — paste a whole batch, run concurrently, export the non-2xx list
2.3 Online debugging
| Pain point | Solution |
|---|---|
| Installing curl / writing scripts | Open a page, zero install |
| Following multi-hop redirects | Auto-expand the full 301→302→200 chain |
| Internal URLs you won't send out | Pure client-side requests, never via our server |
3. Cleaning dirty data: the "fake moves" in status codes
3.1 Typical misleading patterns
| Pattern | What it really means | Harm | Fix |
|---|---|---|---|
| Long 301 chain | http→https→www→/ multi-hop | Link equity loss, slower | Collapse to one hop |
| 200 soft 404 | Missing content still 200 | Flagged duplicate/thin | Return real 404 |
| 403 vs 401 | 401 not logged in / 403 no permission | Broken front-end handling | Separate by semantics |
| 429 rate limit | Hit a rate limit | Misread as an outage | Back off and retry |
| 5xx sporadic | Origin/gateway error | Availability drop | Check if it clusters on one node |
3.2 One-shot sweep script
// check.js — batch fetch and classify
const urls = process.argv.slice(2);
const check = async (u) => {
try {
const r = await fetch(u, { redirect: 'manual' });
return { u, code: r.status };
} catch (e) { return { u, code: 'ERR' }; }
};
Promise.all(urls.map(check)).then(rs => {
rs.filter(r => String(r.code)[0] !== '2')
.forEach(r => console.log(r.code, r.u));
});
3.3 Encoding / redirect checklist
- Confirm the
Locationheader points at the final 200 address - Check whether http/https and www/non-www each add a hop (should be merged)
- Is the CDN caching a 404 as a 200?
- Did a terminal/proxy inject an extra redirect?
Quick verify:
curl -sIL https://example.com | grep -iE "^(HTTP|location)"
# one HTTP/... line per hop; the last is the final state
4. Performance and security
4.1 Don't kill the target with concurrency
// ❌ Wrong: unbounded concurrency
urls.forEach(u => fetch(u));
// ✅ Right: limit concurrency + timeout
const pool = (await import('p-limit')).default;
const limit = pool(10);
await Promise.all(urls.map(u => limit(() =>
fetch(u, { signal: AbortSignal.timeout(5000) })
)));
Production metric: sweeping 1000 URLs at concurrency 10 with a 5s timeout keeps total time bounded and avoids triggering the target's 429.
4.2 Security notes
// Don't send internal/sensitive URLs to third-party online services
// This site's tools are pure client-side; URLs are never stored
const safeCheck = (u) => {
const host = new URL(u).hostname;
if (host === 'localhost' || host.endsWith('.internal')) return 'skip';
return fetch(u, { redirect: 'follow' }).then(r => r.status);
};
5. Team workflow
5.1 Hang the sweep in CI
# .github/workflows/status.yml
- name: Smoke check
run: |
for p in / /api/health; do
c=$(curl -s -o /dev/null -w "%{http_code}" $BASE_URL$p)
[ "$c" = "200" ] || { echo "$p -> $c"; exit 1; }
done
5.2 PR checklist
## HTTP status checks
- [ ] New/changed routes return correct codes (2xx/4xx/5xx semantics)
- [ ] No soft 404 (missing returns 404)
- [ ] Redirect chain is one hop or fewer
- [ ] Errors use 4xx/5xx, not 200 + error
- [ ] Rate-limited endpoints return 429 + Retry-After
6. Tool table
| Scenario | Tool | Key advantage |
|---|---|---|
| Single URL lookup | On-site HTTP Status Checker | Full redirect chain, timing, zero install |
| Batch sweep | On-site HTTP Status Batch | Paste a batch, concurrent, export non-2xx |
| Dead link scan | On-site Broken Link Checker | Scan a page, list every 4xx/5xx link |
| Terminal | curl -sIL | Script-friendly, pipeable |
| DNS/port side | DNS Lookup | Rule out DNS before blaming the server |
7. Pitfalls summary
- Assert status in CI — auto-check key routes return 200 after deploy
- Kill soft 404 — missing means a real 404, don't fake 200
- Collapse redirects — squeeze the chain to one hop
- Read 4xx semantics — 401 not logged in, 403 no permission, 429 rate limit
- Limit concurrency — cap concurrency + timeout on batch sweeps
- Keep URLs local — use client-side tools for internal addresses
- Check the chain — read the full redirect chain, not just the first hop
Closing Thoughts
Checking HTTP status looks like "reading a number," but it is really confirming the server kept its contract.
Make status assertions, chain checks, and batch sweeps into infrastructure — wired into CI, release flow, and alerting.
Next time you get paged at 2 a.m., it won't be because of "one 302 nobody followed to the end."