DevOps Infrastructure

HTTP Status Codes: Reading 200, 404, 502, and 503 to Find Where the Problem Lives

Saturday, 31 Oct 2026 3 min read 20 views

You call an API and get back a 502. The frontend code looks right, retrying still fails, and you start doubting everything. The number was actually telling you where the problem is, if you know how to read it.

What an HTTP Status Code Is

Every time a browser or app sends a request to a server, the server replies with a three-digit status code along with the response. The code tells you the outcome: success, redirect, client error, or server error. It doesn’t replace the response body, but it’s the first line you should check when something goes wrong.

These codes are standardized in RFC 9110, and each has a fixed meaning. That lets every tool, from browsers to proxies to HTTP libraries, interpret them the same way.

Five Classes and Who Is Responsible

The first digit tells you the class:

Class      MeaningUsually belongs to
1xxInformational, request still in progressRarely seen in everyday development
2xxSuccessNo error
3xxRedirectionURL configuration, worth checking
4xxClient errorThe request sent was wrong or unauthorized
5xxServer errorThe server, gateway, or a downstream service is failing

The simplest rule: 4xx usually means the caller needs to fix the request, while 5xx usually means the receiving side needs to check its systems.

Codes You See Every Day

200 (OK) means the request succeeded and the response has content. 201 (Created) means a new resource was created, common when an API adds data.

301 and 302 send the browser to another URL. 301 is permanent, 302 is temporary. Wrong redirects are a common cause of trouble after a website changes its URL structure.

400 (Bad Request) means the server couldn’t understand the request, often because of malformed JSON or missing parameters. 401 (Unauthorized) means authentication is missing, such as not logged in or an expired token. 403 (Forbidden) means you’re authenticated but don’t have permission. Mixing up 401 and 403 is very common, so it’s worth remembering the difference.

404 (Not Found) means no resource exists at that address. For APIs, it usually means a record wasn’t found, though not always.

500 (Internal Server Error) means the server hit an unexpected failure, often an unhandled exception. 502 (Bad Gateway) means a gateway or proxy received an invalid response from the server behind it. 503 (Service Unavailable) means the server temporarily can’t handle requests, usually because of overload or maintenance. 504 (Gateway Timeout) means the gateway waited too long for the upstream server and got no response.

Narrowing Down a Problem With the Status Code

When something breaks, start with the code. For 4xx, check the request itself: URL, method, headers, body, and token. For 5xx, find out whether the server, the gateway, or a downstream service is failing by checking logs and the status of each component. For 502, 503, and 504, the request path is usually longer than it looks, so you need to inspect each hop.

One caveat: not every API returns the right code. Some business errors still return 200 with an error field in the body. Treat the status code as a starting point, not a final verdict, and always check the response body and logs.

You don’t need to memorize hundreds of codes. Remember the classes, a handful of common codes, and ask first which side the error belongs to. That alone saves a lot of debugging time.

References

Ready to Transform Your Business?

Let's discuss how we can help you leverage AI and digital transformation for your enterprise.

Frequently asked questions

What is an HTTP status code?
A three-digit code the server returns with every response, indicating whether the request succeeded, was redirected, or failed on the client or server side.
How do 4xx and 5xx differ?
4xx is a client error, usually fixed by correcting the request. 5xx is a server, gateway, or downstream failure, usually checked on the receiving side.
What is the difference between 401 and 403?
401 means not authenticated (not logged in or expired token). 403 means authenticated but not allowed to access the resource.
How do 502, 503, and 504 differ?
502 means a gateway got an invalid response from the upstream server. 503 means the server is temporarily unable to handle requests. 504 means the gateway timed out waiting for the upstream server.
Do APIs always return the correct status code?
No. Some return 200 with an error field in the body for business errors, so always check the response body and logs.

Share this article