HTML HTTP Status Code

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 3 Try It + full reference
1xx–5xx

Introduction

Every time your browser loads a page, downloads an image, or submits a form, the web server sends back an HTTP status code. That short number tells you whether the request worked, needs a redirect, or failed — and on whose side the problem lies (client or server).

This guide lists the main status codes grouped by class (1xx through 5xx), explains what each one means, and shows how to read codes with fetch() in plain JavaScript Try It demos.

What You’ll Learn

01

What they are

3-digit codes.

02

Five classes

1xx to 5xx.

03

200 OK

Success.

04

301 / 302

Redirects.

05

404 / 403

Client errors.

06

500 / 503

Server errors.

What is HTTP Status Code?

HTTP status codes are three-digit numeric codes that are returned by a web server in response to an HTTP request made by a client (such as a web browser).

These status codes provide information about the status of the request and the outcome of the server’s attempt to fulfill it.

The HTTP status codes are grouped into different classes, each indicating a specific category of response.

The classes are defined by the first digit of the status code:

ClassRangeMeaning
1xx100–199Informational — request received, still processing
2xx200–299Success — request completed as expected
3xx300–399Redirection — client must take further action
4xx400–499Client error — problem with the request
5xx500–599Server error — server failed to fulfill a valid request
💡
Beginner Tip

In JavaScript, after fetch(url), use response.status to read the numeric code and response.ok (true for 200–299) for a quick success check.

1xx — Informational

The request has been received and the server is continuing the process.

Status CodeMessageExplanation
100ContinueUsed to indicate to the client that it can proceed with sending the remainder of the request.
101Switching ProtocolsUsed to indicate that the server is switching protocols as requested by the client.
102ProcessingUsed to indicate that the server has received and is processing the request, but it has not yet completed the process.
103Early HintsUsed to provide the client with some hints or headers before sending the final response. (Formerly called Checkpoint in older drafts.)

2xx — Success

The request was successfully received, understood, and processed by the server.

Status CodeMessageExplanation
200OKUsed to indicate that the client’s request has been successfully received, understood, and processed by the server.
201CreatedUsed to indicate that a new resource has been successfully created as a result of a client’s request.
202AcceptedUsed to indicate that the client’s request has been accepted for processing, but the processing is not yet complete.
203Non-Authoritative InformationUsed to indicate that the server is providing a representation of the requested resource that may be from a third-party or non-origin server.
204No ContentUsed to indicate that the server has successfully processed the client’s request, but there is no content to be returned in the response.
205Reset ContentUsed to instruct the client to reset the current document and clear any form fields or input values.
206Partial ContentUsed to indicate that the server has successfully fulfilled a partial GET request from the client.

3xx — Redirection

The client needs to take additional action to complete the request.

Status CodeMessageExplanation
300Multiple ChoicesUsed to indicate that the requested resource has multiple choices available, and the client should choose one of them to proceed.
301Moved PermanentlyUsed to indicate that the requested resource has been permanently moved to a new location.
302FoundUsed to indicate that the requested resource has been temporarily moved to a different location.
303See OtherUsed to indicate that the client should retrieve the requested resource from a different location using a GET request.
304Not ModifiedUsed to indicate that the requested resource has not been modified since the client’s last request, and the client can use its cached version of the resource.
306(Unused)Reserved; no longer used. Listed in some references for historical completeness.
307Temporary RedirectUsed to indicate that the requested resource has been temporarily moved to a different location.
308Permanent RedirectUsed to indicate that the requested resource has been permanently moved to a different location.

4xx — Client Error

The request contains incorrect syntax or cannot be fulfilled by the server due to client error.

Status CodeMessageExplanation
400Bad RequestUsed to indicate that the server cannot process the client’s request due to malformed syntax or other client-side errors.
401UnauthorizedUsed to indicate that the client’s request lacks valid authentication credentials for the requested resource.
402Payment RequiredUsed to indicate that payment is required to access the requested resource.
403ForbiddenUsed to indicate that the client’s request is understood by the server, but the server refuses to fulfill it.
404Not FoundUsed to indicate that the server cannot find the requested resource.
405Method Not AllowedUsed to indicate that the requested HTTP method is not allowed for the given resource.
406Not AcceptableUsed to indicate that the server cannot generate a response that satisfies the client’s requested content requirements.
407Proxy Authentication RequiredUsed to indicate that the client must authenticate itself with a proxy server before making the requested request. It is part of the HTTP 4xx status code class.
408Request TimeoutUsed to indicate that the server did not receive a complete request from the client within the server’s specified timeout period.
409ConflictUsed to indicate a conflict between the client’s request and the current state of the server.
410GoneUsed to indicate that the requested resource is no longer available on the server and will not be available again in the future.
411Length RequiredUsed to indicate that the server requires the “Content-Length” header to be included in the client’s request.
412Precondition FailedUsed to indicate that one or more conditions specified in the client’s request headers are not met by the server.
413Content Too LargeUsed to indicate that the server refuses to process the request because the payload (e.g., request body) is too large. (Also known as Payload Too Large.)
414URI Too LongUsed to indicate that the server cannot process the request because the URI (Uniform Resource Identifier) provided by the client is too long.
415Unsupported Media TypeUsed to indicate that the server refuses to accept the request because the media type of the request entity (e.g., request body) is not supported or not acceptable.
416Range Not SatisfiableUsed to indicate that the server cannot fulfill the client’s request because the requested range of a resource is not available or valid.
417Expectation FailedUsed to indicate that the server cannot meet the expectations specified in the “Expect” request header field.

5xx — Server Error

The server encountered an error while processing the request.

Status CodeMessageExplanation
500Internal Server ErrorUsed to indicate an unexpected condition occurred on the server that prevented it from fulfilling the client’s request.
501Not ImplementedUsed to indicate that the server does not support the functionality required to fulfill the client’s request.
502Bad GatewayUsed to indicate that the server acting as a gateway or proxy received an invalid response from an upstream server.
503Service UnavailableUsed to indicate that the server is temporarily unable to handle the client’s request.
504Gateway TimeoutUsed to indicate that the server acting as a gateway or proxy did not receive a timely response from an upstream server.
505HTTP Version Not SupportedUsed to indicate that the server does not support the HTTP protocol version used in the client’s request.
507Insufficient StorageUsed to indicate that the server is unable to store the representation needed to complete the client’s request.
511Network Authentication RequiredUsed to indicate that the client must authenticate itself to gain network access.

These status codes are an essential part of the HTTP protocol and are used to communicate the outcome of a request between the client and the server.

They provide valuable information for developers, allowing them to handle different scenarios and troubleshoot issues when interacting with web servers.

⚡ Quick Reference — Most Common Codes

Success
200 OK

Page loaded

Redirect
301 / 302

New URL

Not found
404

Missing page

Server
500

Server bug

Examples Gallery

Three Try It demos show how to read real HTTP status codes with fetch() and look up common codes. Plain HTML, no CSS.

Example 1 — Read 200 OK with fetch()

js
fetch('/html/status-code')
  .then(function (response) {
    console.log(response.status);      // 200
    console.log(response.statusText);  // OK
    console.log(response.ok);          // true
  });
Try It Yourself

How It Works

response.ok is shorthand for “status is in the 200–299 range.”

Example 2 — Trigger 404 Not Found

js
fetch('/html/this-page-does-not-exist')
  .then(function (response) {
    console.log(response.status);  // 404
    console.log(response.ok);      // false
  });
Try It Yourself

How It Works

fetch() does not throw on 404 — you must check response.status yourself.

Example 3 — Status Code Lookup

Type a code and see its class (1xx–5xx) plus a short meaning for common values:

Try It Yourself

How It Works

Divide the code by 100 and take the integer part: 404 → 4xx (client error).

🚀 Why Status Codes Matter

  • Debugging — a 4xx points to the request or URL; a 5xx points to server code or infrastructure.
  • SEO — search engines treat 301/308 differently from 302; soft 404s (200 with empty content) hurt rankings.
  • APIs — REST APIs use 201 for create, 204 for delete-with-no-body, 409 for conflicts.
  • Caching — 304 Not Modified saves bandwidth by reusing cached assets.
  • User experience — custom 404 and 500 pages guide visitors when something goes wrong.
  • Monitoring — uptime tools alert when your site starts returning 503 or 502.

🧠 How HTTP Status Codes Work (Step by Step)

1

Client sends a request

The browser issues GET /page HTTP/1.1 (or POST, PUT, etc.) to the server.

2

Server processes it

The server routes the URL, runs code, reads files, or talks to a database.

3

Server sends status line

The first line of the response is HTTP/1.1 200 OK (code + reason phrase).

4

Headers and body follow

Content-Type, Cache-Control, etc., then HTML, JSON, or other data.

5

Client reacts

Browsers render HTML on 200, follow Location on 3xx, show error pages on 4xx/5xx.

Best Practices

  • Return the right code — do not send 200 OK for a missing page; use 404 (or 410 if gone permanently).
  • Use 301 for permanent moves — when renaming URLs, redirect old paths so bookmarks and SEO transfer.
  • Custom error pages — friendly 404 and 500 HTML pages help users recover.
  • Check APIs explicitly — always inspect response.status in fetch handlers.
  • Log 5xx on the server — client-side code cannot fix internal server errors; server logs are essential.

Conclusion

HTTP status codes are the language servers use to report what happened to each request. Memorize the five classes first, then the handful you see daily: 200, 301, 302, 404, and 500. Use the full tables above as a reference when you encounter less common codes.

Practice reading live codes in the Try It editor, then continue with HTML drag and drop via the draggable attribute.

🏆 Key Takeaways

Five facts to remember about HTTP status codes.

🔢 01

3 digits

Code + message.

Format
02

2xx

Success.

Class
🔄 03

3xx

Redirect.

Class
🚫 04

4xx

Client fault.

Class
⚠️ 05

5xx

Server fault.

Class

❓ Frequently Asked Questions

An HTTP status code is a three-digit number the server sends in the response line (for example 200 OK or 404 Not Found). It tells the browser whether the request succeeded, was redirected, or failed.
200 OK means the server successfully received, understood, and processed the request. It is the standard success code for GET requests that return a page or resource.
301 Moved Permanently tells browsers and search engines the URL has changed forever — link equity should move to the new URL. 302 Found is a temporary redirect — the original URL may still be the canonical one.
404 means the server could not find a resource at the requested URL. Common causes: typo in the link, deleted page, or missing file. Fix broken links or add a redirect to the correct page.
500 indicates an unexpected problem on the server while processing a valid request — often a bug in server-side code, misconfiguration, or database failure. Check server logs to diagnose.
Open DevTools → Network tab, reload the page, and click a request. The Status column shows the code. In JavaScript, fetch() returns response.status after a request completes.
Did you know?

Status codes are not part of HTML markup — they belong to the HTTP protocol layer. HTML pages are just one type of content the server may return alongside the status line. You see them in DevTools Network tab, not in your <html> source.

See real status codes with fetch()

Click a button in the Try It editor and read response.status from a live HTTP response — no extra libraries needed.

Open Try It editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful