1. Home
  2. Blog
  3. Software Development

Software Development

HTTP Status Codes Cheat Sheet for Developers and Testers

Every common HTTP status code from 1xx to 5xx in one place, with plain-English meanings, API examples and what testers should verify for each.

By Stack QuoraUpdated Oct 30, 20268 min read
HTTP status codes cheat sheet for developers and testers

Key takeaways

  • The first digit tells you the class: 1xx info, 2xx success, 3xx redirect, 4xx client error, 5xx server error.
  • Use the most specific code: 201 for created, 204 for no content, 422 for validation errors.
  • 401 means “not authenticated”; 403 means “authenticated but not allowed”.
  • Test both the status code and the response body, because a wrong code with a good body is still a bug.

Every web request ends with a three-digit number that says whether it worked. This HTTP status codes cheat sheet collects the codes you will meet most often when building or testing web apps and APIs.

Developers use status codes to tell clients what happened. Testers use them to check that the system behaves correctly in both good and bad situations. A clear grasp of HTTP status codes saves hours of debugging, especially when you test APIs.

The definitions follow the HTTP standard in RFC 9110, and the MDN status code reference is a handy companion. If APIs are new to you, start with our guide on what is an API.

The five classes of HTTP status codes

Class Meaning Example
1xx Informational, request received 100 Continue
2xx Success 200 OK
3xx Redirection, more action needed 301 Moved Permanently
4xx Client error, the request is wrong 404 Not Found
5xx Server error, the server failed 500 Internal Server Error

HTTP status codes cheat sheet: 2xx success

Code Name When to use it
200 OK Request succeeded; response has a body (GET, PUT).
201 Created A new resource was created (POST). Usually includes a Location header.
202 Accepted Request accepted for later processing, such as a background job.
204 No Content Success with no body, common for DELETE.
206 Partial Content A range of the resource was returned, such as video streaming.

HTTP status codes cheat sheet: 3xx redirection codes

Code Name When to use it
301 Moved Permanently The URL has changed for good; search engines update links.
302 Found Temporary redirect.
304 Not Modified Cached copy is still valid.
307 Temporary Redirect Temporary redirect that keeps the HTTP method.
308 Permanent Redirect Permanent redirect that keeps the HTTP method.

HTTP status codes cheat sheet: 4xx client error codes

Code Name Typical cause
400 Bad Request Malformed JSON or missing required data.
401 Unauthorized No valid credentials or an expired token.
403 Forbidden Logged in but not allowed to do this.
404 Not Found The resource or URL does not exist.
405 Method Not Allowed Wrong HTTP method for this endpoint.
409 Conflict State conflict, such as a duplicate record.
410 Gone Resource was removed on purpose.
415 Unsupported Media Type Wrong Content-Type header.
422 Unprocessable Content Valid format but failed validation rules.
429 Too Many Requests Rate limit exceeded; check the Retry-After header.

401 vs 403 vs 404

These three cause the most confusion. A 401 means the server does not know who you are. A 403 means it knows you but you lack permission. A 404 means the thing does not exist, although some APIs return 404 instead of 403 to avoid revealing that a private resource exists.

HTTP status codes cheat sheet: 5xx server error codes

Code Name Typical cause
500 Internal Server Error Unhandled exception on the server.
501 Not Implemented The server does not support the feature.
502 Bad Gateway A proxy got an invalid reply from an upstream server.
503 Service Unavailable Overloaded or down for maintenance.
504 Gateway Timeout An upstream server took too long to respond.

Quick tip: A 5xx response should never expose stack traces or database errors to users. Test that error bodies are safe as well as correct.

How to test HTTP status codes

For each endpoint, write at least one test for the happy path and for each expected error. Here is a short Python example with the requests library:

import requests

BASE = "https://api.example.com"

def test_create_user_returns_201():
    r = requests.post(f"{BASE}/users", json={"name": "Asha", "email": "asha@example.com"})
    assert r.status_code == 201
    assert "id" in r.json()

def test_missing_token_returns_401():
    r = requests.get(f"{BASE}/me")
    assert r.status_code == 401

def test_unknown_user_returns_404():
    r = requests.get(f"{BASE}/users/999999", headers={"Authorization": "Bearer TOKEN"})
    assert r.status_code == 404

Use this checklist when you review an API:

  • Successful create returns 201, not 200.
  • Delete returns 204 or 200 consistently.
  • Validation failures return 400 or 422 with helpful messages.
  • Missing or expired tokens return 401; missing permissions return 403.
  • Unknown IDs return 404, not 500.
  • Rate limiting returns 429 with a Retry-After header.
  • Server failures return 5xx without leaking internal details.

Our API testing with Postman guide shows how to automate these checks in a collection, and our REST API best practices article explains how to pick the right code when designing endpoints.

Final thoughts

Keep this HTTP status codes cheat sheet bookmarked. Learn the five classes first, then the ten or so codes you meet daily: 200, 201, 204, 301, 400, 401, 403, 404, 429 and 500. Use the most accurate code in your API and verify every expected error in your tests.

Frequently asked questions

What do the HTTP status code classes mean?

1xx is informational, 2xx is success, 3xx is redirection, 4xx is a client error and 5xx is a server error.

What is the difference between 401 and 403?

401 means the request lacks valid authentication. 403 means the user is authenticated but not permitted to perform the action.

Should a POST return 200 or 201?

Return 201 Created when a new resource is created. Use 200 only when the POST performs an action without creating something.

When should an API return 422?

Use 422 when the request is well formed but fails business or validation rules. Some teams use 400 for this, so stay consistent.

What causes a 502 or 504 error?

Both involve a gateway or proxy. 502 means it received a bad reply from an upstream server, while 504 means the upstream server timed out.

Keep learning

Work with Stack Quora

Need help with testing, WordPress or SEO?

We help teams ship better software and grow their sites. Tell us what you are working on and we will suggest a clear next step.

Keep reading

More guides on testing, AI & modern development

Enjoyed this article? Pick a topic and jump straight into our newest tutorials.

Databases & SQL

SQL GROUP BY and HAVING Explained With Examples

SQL GROUP BY and HAVING explained with sample tables, aggregate functions, WHERE vs HAVING and common mistakes, with queries you…

Read article →
Software Development

HTTP Status Codes Cheat Sheet for Developers and Testers

An HTTP status codes cheat sheet for developers and testers: every common 1xx to 5xx code, what it means and…

Read article →
Test Automation

Selenium WebDriver Waits Explained: Implicit, Explicit and Fluent

Selenium waits explained: implicit, explicit and fluent waits with Python examples, when to use each and how to remove flaky…

Read article →
Software Testing

Test Automation Mistakes Beginners Make and How to Avoid Them

The 10 test automation mistakes beginners make, from flaky waits to automating everything, and the practical fixes that keep your…

Read article →
Artificial Intelligence

Claude Opus 5.5 vs Sonnet 5.5: Pricing, Speed and When to Use Each

Claude Opus 5.5 vs Sonnet 5.5 compared: listed pricing, context, speed and a simple guide to which model fits coding,…

Read article →
Artificial Intelligence

Best AI Code Review Tools for Developers in 2026

Compare the best AI code review tools in 2026: CodeRabbit, GitHub Copilot, Qodo, Greptile and more. See what each does,…

Read article →
Software Development

What Is an API? A Simple Guide for Beginners

What is an API? Learn in plain English how APIs work, the main types, HTTP methods and status codes, with…

Read article →
Test Automation

Playwright Locators Cheat Sheet With Examples

A practical Playwright locators cheat sheet: getByRole, getByText, getByLabel, test IDs, CSS, filtering and chaining, with copy-paste examples for stable…

Read article →
Software Testing

How to Write Test Cases: Format, Examples and Best Practices

Learn how to write test cases with a clear format, login and checkout examples, a reusable template and best practices…

Read article →
Artificial Intelligence

Gemini 4 Argon: What’s New and How It Compares to Earlier Gemini Models

Gemini 4 Argon is Google's new flagship reasoning model. See its API limits, app features, coding focus and how to…

Read article →
Databases & SQL

SQL Joins Explained With Examples (Inner, Left, Right, Full)

SQL joins explained step by step with sample tables and queries: INNER, LEFT, RIGHT, FULL, CROSS and SELF joins, plus…

Read article →
Software Development

Python Virtual Environment Tutorial: venv, pip and uv

Learn how to create, activate and manage a Python virtual environment with venv, pip and uv, including requirements files, .gitignore…

Read article →
Test Automation

Playwright vs Cypress in 2026: Which Should You Pick?

Playwright vs Cypress compared for 2026: browsers, languages, speed, debugging, parallel runs, CI and cost. Find out which end-to-end testing…

Read article →
Software Testing

Smoke Testing vs Sanity Testing: Differences With Real Examples

Smoke testing checks that a build is stable enough to test. Sanity testing checks that a specific fix works. Learn…

Read article →
Artificial Intelligence

Claude Haiku 5.5: Features, Pricing and Use Cases for Developers

Claude Haiku 5.5 is Anthropic's fastest and lowest-priced model. See its 1M-token context, pricing, API changes and the best use…

Read article →
Software Testing

End to End Testing Best Practices: Boost Reliability in 2026

Flaky tests waste time and hide real bugs. Learn end to end testing best practices that make your tests stable,…

Read article →
Test Automation

Best Test Automation Framework 2026: Choose the Right One

Not sure which test automation framework to pick? Compare the main types, use a simple checklist, and see how Playwright,…

Read article →
Artificial Intelligence

AI Agents Best Practices: Deploy Reliable Intelligent Bots

AI agents can save hours of work, but only when they are built with care. Learn AI agents best practices…

Read article →
Test Automation

Test Automation Framework Example: Build a Scalable Suite

See a real test automation framework example with folder layout, page objects, test data and CI steps. Copy the structure…

Read article →
Software Testing

Best Test Automation Tools 2026: Top Picks for QA Teams

Compare the best test automation tools in 2026 for web, mobile and API testing. See what each tool does well,…

Read article →
Software Development

REST API Best Practices 2026: Build Scalable Services

Learn REST API best practices for 2026: clear URLs, correct status codes, versioning, pagination, security and error handling, with simple…

Read article →
Artificial Intelligence

MCP Stateless Architecture: What’s New in MCP 2026

The MCP 2026-07-28 spec removes sessions and the handshake. See how stateless MCP works, what breaks, what gets easier to…

Read article →
Artificial Intelligence

WebMCP Explained: How AI Agents Will Interact With Websites

WebMCP lets a website publish tools that AI agents can call directly. Learn the Declarative and Imperative APIs, code examples,…

Read article →
Databases & SQL

SQL Tutorial for Beginners: Complete Guide to SQL in 2026

Learn SQL from scratch. Create tables, insert and query data, filter, sort, group, join tables and use subqueries and indexes,…

Read article →
Software Development

Git Tutorial for Beginners: Complete Guide to Git and GitHub in 2026

Learn Git from zero. Create repositories, commit, branch, merge, fix mistakes and work with GitHub pull requests, using simple commands…

Read article →
DevOps

Docker Tutorial for Beginners: Complete Guide to Docker in 2026

New to Docker? Learn containers, images, Dockerfiles, volumes, networks and Docker Compose with simple commands and a small project you…

Read article →
Databases & SQL

Vector Databases Explained: How Vector Search and AI Databases Work in 2026

Vector databases search by meaning, not just keywords. Learn embeddings, similarity search, HNSW indexes, pgvector and how to choose the…

Read article →
Software Testing

API Testing with Postman: A Complete Guide for Beginners and QA Testers

Learn API testing with Postman from scratch. Send requests, read status codes, add auth, write test scripts, build collections and…

Read article →
DevOps

GitHub Actions CI/CD: A Complete Guide to Automating Software Builds, Tests and Deployments

Learn GitHub Actions from scratch. Build a CI/CD workflow that runs tests, builds your app and deploys it, with simple…

Read article →