Back to Blog Index
Developer Workflows13 min read

HTTP Status Codes & API Debugging: A Complete Reference for Backend and Frontend Engineers

Master HTTP response status codes from 1xx to 5xx, understand their implications for API design, learn debugging strategies for common error codes, and build resilient error handling.

ToolZeno Editorial Team

Software Architecture & Security Guild

Published 2026-06-25 (Updated 2026-07-30)
#HTTP#API#REST#Status Codes#Debugging#Backend

Understanding HTTP Status Code Classes (1xx through 5xx)

HTTP status codes are three-digit integers returned by servers in the response header to indicate the outcome of a client's request. They are grouped into five classes, each representing a different category of response.

1xx (Informational) — These codes indicate that the server has received the request and is continuing to process it. The most common is 100 Continue, which tells the client that the server has received the request headers and the client should proceed to send the request body. 101 Switching Protocols is used when upgrading from HTTP to WebSocket connections.

2xx (Success) — These codes indicate that the request was successfully received, understood, and accepted. 200 OK is the standard success response. 201 Created confirms that a new resource was created (used after POST requests). 204 No Content indicates success but no response body (common for DELETE requests and PUT updates). 202 Accepted means the request has been queued for asynchronous processing.

3xx (Redirection) — These codes indicate that further action is needed to complete the request. 301 Moved Permanently tells search engines and browsers to update their records. 302 Found (commonly used for temporary redirects) and 307 Temporary Redirect preserve the request method during redirection. 304 Not Modified indicates the cached version is still valid.

4xx (Client Error) — These codes indicate that the client sent an invalid request. 400 Bad Request means malformed syntax. 401 Unauthorized means authentication is required. 403 Forbidden means the authenticated user lacks permission. 404 Not Found means the resource doesn't exist. 409 Conflict indicates the request conflicts with current state. 429 Too Many Requests means rate limiting is in effect.

5xx (Server Error) — These codes indicate that the server failed to process a valid request. 500 Internal Server Error is a generic catch-all. 502 Bad Gateway means an upstream service returned an invalid response. 503 Service Unavailable means the server is temporarily overloaded or under maintenance. 504 Gateway Timeout means an upstream service didn't respond in time.

Choosing Correct Status Codes for REST API Design

Correct status code usage is a cornerstone of well-designed REST APIs. Many APIs misuse status codes by returning 200 OK for every response and embedding error information in the response body. This anti-pattern breaks HTTP client libraries, caching layers, monitoring dashboards, and retry logic that depend on status codes to determine request outcomes.

For resource creation (POST), return 201 Created with a Location header pointing to the newly created resource URL. Include the created resource in the response body so the client can read any server-generated fields (like ID, timestamps, or computed defaults) without an additional GET request.

For updates (PUT/PATCH), return 200 OK with the updated resource in the body, or 204 No Content if no response body is needed. If the update fails due to concurrent modification, return 409 Conflict with details about the conflicting state.

For deletion (DELETE), return 204 No Content on success. If the resource has already been deleted, return 404 Not Found (idempotent) or 204 No Content (tolerant) depending on your API's idempotency guarantees.

For validation errors, return 422 Unprocessable Entity (not 400 Bad Request) with a structured error response body listing each invalid field, the validation rule that failed, and a human-readable error message. This distinction matters: 400 means the request is syntactically malformed (can't be parsed), while 422 means the request is syntactically valid but semantically incorrect (parsed successfully but contains invalid values).

  • Use 201 Created for POST (resource creation), not 200 OK.
  • Use 204 No Content for DELETE success and body-less PUT updates.
  • Use 422 Unprocessable Entity for validation errors, not 400 Bad Request.
  • Use 409 Conflict for concurrent modification errors and state conflicts.
  • Use 429 Too Many Requests with Retry-After header for rate limiting.
  • Never return 200 OK for error responses — this breaks client error handling.

Debugging Common HTTP Errors: 401, 403, 404, 500, 502, 503

Each HTTP error code points to a different category of problem. Understanding the distinction accelerates debugging by narrowing the investigation to the correct layer of the technology stack.

401 Unauthorized — The request lacks valid authentication credentials. Debug by checking: Is the Authorization header present? Is the token format correct (Bearer vs Basic)? Has the token expired? Is the token signed with the correct key? Is the authentication middleware correctly configured? Check server logs for authentication rejection reasons.

403 Forbidden — Authentication succeeded, but the authenticated user lacks permission. Debug by checking: What role or permission is required? Does the user's token contain the necessary claims? Is the resource's access control list (ACL) correctly configured? Are permission checks evaluating the correct scope?

404 Not Found — The requested URL doesn't map to any resource. Debug by checking: Is the URL path correct (case sensitivity matters in most servers)? Does the route/endpoint exist in the router configuration? Has the resource been deleted? Is the ID format correct (UUID vs integer)?

500 Internal Server Error — An unhandled exception occurred in the server code. Debug by checking: server application logs (not just the HTTP response), recent deployments that may have introduced bugs, database connectivity, external service dependencies, and memory/disk resource exhaustion.

502 Bad Gateway — A reverse proxy or load balancer received an invalid response from the upstream application server. Debug by checking: Is the application process running? Is it listening on the expected port? Is the proxy configuration pointing to the correct backend? Has the application crashed and been restarted by the process manager?

503 Service Unavailable — The server is temporarily unable to handle requests. Debug by checking: Is the server under heavy load (CPU/memory exhaustion)? Is there an active deployment or maintenance window? Has a circuit breaker tripped on a critical dependency? Is there a database connection pool exhaustion?

API Testing and Debugging Tools for Developers

Effective API debugging requires tools that let you construct, send, and inspect HTTP requests with full control over headers, methods, body content, and authentication credentials.

Browser DevTools Network Tab is the first tool for debugging frontend API calls. It shows every HTTP request made by the page, including the full request/response headers, body content, timing breakdown, and status code. Filter by XHR/Fetch to see only API calls. The "Copy as cURL" feature lets you reproduce any request from the command line.

cURL is the universal command-line HTTP client. It supports all HTTP methods, custom headers, request bodies, authentication, cookies, and SSL certificates. Building cURL commands manually is tedious for complex requests — ToolZeno's cURL Command Builder generates correctly formatted commands with proper escaping from a visual interface.

REST API testing tools allow you to save, organise, and replay API requests. ToolZeno's REST Request Builder provides a browser-based interface for constructing requests with visual header and body editors, without requiring software installation or account creation. All request data remains local to your browser.

HTTP Status Lookup tools provide quick reference for unfamiliar status codes encountered during debugging. Rather than searching documentation, ToolZeno's HTTP Status Lookup provides instant descriptions, common causes, and debugging suggestions for every standard HTTP status code.

The critical advantage of browser-based API debugging tools is privacy. When testing against staging or production APIs, request headers contain authentication tokens, API keys, and session cookies. Desktop applications like Postman have faced scrutiny over telemetry and cloud sync features that may transmit API credentials. Client-side browser tools process everything locally with zero data transmission.

Frequently Asked Questions

Q:What is the difference between 401 Unauthorized and 403 Forbidden?

401 means the request lacks valid authentication credentials (the user is not logged in or the token is invalid/expired). 403 means the user is authenticated but doesn't have permission to access the requested resource. Fix 401 by re-authenticating; fix 403 by requesting the necessary permissions.

Q:Should I use 400 Bad Request or 422 Unprocessable Entity for validation errors?

Use 400 for requests that cannot be parsed (malformed JSON, missing required headers). Use 422 for requests that are syntactically valid but contain semantically invalid data (email format wrong, number out of range). 422 is more specific and informative for API consumers.

Q:What does a 502 Bad Gateway error mean and how do I fix it?

502 means a reverse proxy (Nginx, Cloudflare, AWS ALB) received an invalid response from the upstream application server. Common causes include: the application process has crashed, it's not listening on the expected port, or the response exceeds size/timeout limits. Check application server logs and process status.

Q:Why do I get CORS errors and how are they related to HTTP status codes?

CORS errors occur when the browser blocks cross-origin requests due to missing or incorrect Access-Control-Allow-Origin headers. The actual HTTP status code may be 200 (the server responded successfully), but the browser refuses to expose the response to JavaScript. Fix by configuring CORS headers on the API server.

Explore More Technical Guides

Design & Accessibility

Understanding Web Accessibility & WCAG 2.1 Contrast Ratios for Modern Web Apps

A comprehensive developer's masterclass on WCAG 2.1 AA/AAA color contrast standards, relative luminance math, color blindness vision deficiencies, and building accessible UI design systems.

12 min readRead
Security & Cryptography

JSON Web Tokens (JWT) Deep-Dive: Architecture, Security Standards, and Local Debugging

An in-depth security engineering guide to RFC 7519 JWT structure, digital signatures (HS256 vs RS256), token vulnerability vectors, and safe client-side debugging.

14 min readRead
Performance & Optimization

Image Optimization Strategies for Core Web Vitals: WebP, SVG, and Compression Techniques

Master image compression algorithms, next-generation WebP/AVIF file formats, SVG vector minification, and responsive image loading to achieve 100 Lighthouse performance scores.

12 min readRead
Security & Cryptography

Understanding Password Entropy, Key Derivation, and Cryptographic Hash Functions

Explore the mathematics of password entropy, NIST 800-63B security standards, salt iterations, and SHA-256 vs Argon2 key derivation functions for modern authentication systems.

13 min readRead
Developer Workflows

The Developer's Guide to Cron Expressions, Syntax Parsing, and Execution Schedules

Learn standard 5-field cron syntax, special wildcards, Quartz scheduler differences, common scheduling patterns, and how to validate background cron jobs accurately.

11 min readRead
Developer Workflows

JSON Formatting & Validation in High-Performance Web Applications

Discover best practices for parsing multi-megabyte JSON payloads, handling circular object references, schema validation, Web Worker parsing, and safe browser-based formatting.

12 min readRead
Developer Workflows

Base64 Encoding & Decoding: How It Works, When to Use It, and Common Pitfalls

A thorough technical guide to the Base64 encoding algorithm, its mathematical foundations, practical use cases in web development, and critical security misunderstandings.

11 min readRead
Developer Workflows

Regular Expressions Mastery: Pattern Syntax, Performance Traps, and Real-World Recipes

Master regex pattern syntax from fundamentals to advanced lookaheads, understand catastrophic backtracking, and learn production-tested patterns for email, URL, and data validation.

14 min readRead