AI HTTP Status Codes — The Complete Quick Reference Guide

Published February 23, 2026 · 9 min read · Developer Tools

Your API returns a 403. The frontend developer says it should be a 401. The product manager asks why users see a "forbidden" message when they are clearly logged in. Meanwhile, the load balancer is throwing 502s that have nothing to do with your code. HTTP status codes seem simple until you actually have to choose the right one — or debug the wrong one in production.

An HTTP status code reference tool gives you instant answers. Search by code number, filter by category, and see real-world examples of when each code applies. No more guessing whether you need a 301 or a 308.

The Five Categories of HTTP Status Codes

HTTP response codes are grouped into five classes based on their first digit. Understanding the categories helps you narrow down problems even before you look up the specific code.

1xx — Informational

These are provisional responses. The server received the request and is continuing to process it. You rarely see these in application code, but they matter for protocol-level operations:

2xx — Success

The request was received, understood, and accepted. These are the codes you want to see:

3xx — Redirection

The client needs to take additional action to complete the request. Getting redirects right is critical for SEO and user experience:

SEO tip: Use 301 for permanent URL changes (domain migration, slug changes). Use 302 for temporary situations (A/B tests, maintenance). Using the wrong redirect type can hurt your search rankings. Check your redirects with an SSL checker to ensure HTTPS redirects are configured correctly.

4xx — Client Errors

The request contains an error on the client side. These are the codes that cause the most confusion:

5xx — Server Errors

Something went wrong on the server side. These codes mean your code (or infrastructure) has a problem:

The 401 vs 403 Debate

This is the most commonly confused pair of HTTP status codes. Here is the definitive answer:

Use 401 when the client has not provided authentication credentials, or the credentials are invalid. The response should include a WWW-Authenticate header indicating the authentication scheme. The client can fix this by logging in.

Use 403 when the client is authenticated (you know who they are) but they do not have permission to access the resource. Re-authenticating will not help. They need different permissions.

// No token provided or token is invalid/expired
GET /api/admin/users
→ 401 Unauthorized
   WWW-Authenticate: Bearer

// Valid token, but user is not an admin
GET /api/admin/users
Authorization: Bearer valid-user-token
→ 403 Forbidden
   {"error": "Admin role required"}

Some APIs use 404 instead of 403 to avoid revealing that a resource exists. This is a valid security practice — if an attacker should not even know the endpoint exists, returning 404 is safer than 403.

Choosing the Right Status Code for Your REST API

A well-designed API uses status codes consistently. Here is a practical mapping for common CRUD operations:

POST   /users          → 201 Created (with Location header)
GET    /users           → 200 OK
GET    /users/123       → 200 OK (or 404 if not found)
PUT    /users/123       → 200 OK (or 204 No Content)
PATCH  /users/123       → 200 OK (or 204 No Content)
DELETE /users/123       → 204 No Content
POST   /users (dup)     → 409 Conflict
POST   /users (invalid) → 422 Unprocessable Entity

Consistency matters more than perfection. Pick a convention and stick with it across your entire API. Document your status code usage in your API documentation so consumers know what to expect.

Debugging HTTP Errors in Production

502 and 504 from Nginx

These are the most common production headaches. A 502 means Nginx connected to your application but got garbage back (or the connection was reset). A 504 means Nginx waited too long and gave up. Common causes:

Check your application logs first, not Nginx logs. The Nginx error log will say "upstream prematurely closed connection" which tells you nothing useful. Your application log will have the actual stack trace. Use DNS lookup tools to verify your domain is resolving correctly if the issue seems network-related.

Mysterious 403s

When you get 403s that your application code is not generating, check these in order: file permissions on static assets (use a chmod calculator to verify), directory listing disabled in Nginx, WAF or CDN rules blocking requests, CORS preflight failures (which actually return different codes but often get reported as 403).

Look up any HTTP status code instantly

Search by code number, filter by category, and see real-world examples. Stop guessing whether you need a 301 or 308.

Try AI HTTP Status Codes →

Status Codes That Most Developers Never Use (But Should)

Beyond the common codes, several underused status codes can improve your API design:

Using precise status codes makes your API self-documenting. A client that receives a 429 with Retry-After: 60 knows exactly what to do without reading any documentation. Pair this with a solid JSON response format and your API becomes a pleasure to integrate with.

Related Tools for API Development

HTTP status codes are just one piece of the API puzzle. Here are other tools that complement your workflow: