Join our Newsletter — 33% off our NHI Course
Home› Guides› HTTP Status Codes for Beginners: What 401, 403…
Guide Web & API Security

HTTP Status Codes for Beginners: What 401, 403 and 500 Tell You About Security

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 1 December 2026 11 min read
On this page

An HTTP status code is the three-digit number a web server sends back to say how a request went.

This guide is for testers, support staff, new developers and anyone who reads web logs. You do not need to write code. If you have ever seen "404 Not Found" in a browser, you have already met one.

In short

  • Every reply from a web server or API starts with a status code. The first digit tells you the family.
  • 401 means the server did not get valid proof of who is asking. 403 means it knows enough and still says no.
  • 500 means the server itself hit a fault. The reply should stay short and keep the technical details private.
  • Patterns of codes in logs, such as many 401s in a row, can be an early sign of trouble.

What you will learn

  • Read the five families of status codes at a glance.
  • Tell 401 and 403 apart, and explain why the difference matters.
  • Spot when an error page gives away too much.
  • Use status codes in logs as simple warning signs.
Request
a message from a browser, app or script asking a server for something.
Response
the server's reply, which starts with a status code.
Credentials
the proof a caller sends to show who it is, such as a password, token or key.

What are HTTP status codes?

Think of a reception desk in an office building. You hand over a request and get a quick answer. It might be "here you go", "show me your badge", "you are not allowed in" or "sorry, our system is down".

A web server works the same way. Each reply carries a three-digit number. The first digit sorts it into a family. Codes starting with 4 mean the client seems to have made a mistake, and codes starting with 5 mean the server has a problem [1]. Codes starting with 3 mean the caller needs to take another step, such as going to a new address [1].

FamilyPlain meaningCommon example
1xxInformation: carry on100 Continue
2xxIt worked200 OK
3xxGo somewhere else or take another stepA move to a new address
4xxThe request has a problem401, 403, 404, 429
5xxThe server has a problem500

Where the comparison stops working: a receptionist can explain and ask questions. A status code is just a number, and servers do not always pick the right one.

New to how requests travel? Read API Security for Beginners first.

Why does it matter?

Status codes are small, but they show whether checks on identity and access are working. They also show up in every log, which makes them cheap warning signs.

If you build or test web apps

What could happen: a page returns 200 OK to someone who should have been refused, and nobody notices.

Check this: test each private page with no credentials and with the wrong user. Expect 401 or 403.

Next: Broken Access Control for Beginners

If you watch logs or alerts

What could happen: a burst of 401s from one source goes unread, though it may be someone guessing passwords or keys.

Check this: set a simple alert for unusual spikes in 401, 403 and 429 replies.

Next: Logging for Beginners

If you run a service with an API

What could happen: a 500 error page shows software names and versions, which helps an attacker plan.

Check this: trigger an error on purpose in a test system and read what the reply reveals.

Next: Error Handling for Beginners

What does it look like?

Here are made-up log lines from a small web service. Each line shows the time, the caller, the path asked for and the status code.

Example only. All values are made up.

09:00:01 caller=EXAMPLE-app  GET /reports      200   (1)
09:00:02 caller=none         GET /reports      401   (2)
09:00:03 caller=EXAMPLE-bot  GET /admin        403   (3)
09:00:04 caller=EXAMPLE-bot  GET /old-page     404   (4)
09:00:05 caller=EXAMPLE-bot  GET /reports      429   (5)
09:00:06 caller=EXAMPLE-app  GET /search?q=0000 500  (6)
  1. 200: the request worked and the caller got the report.
  2. 401: no valid credentials came with the request, so the server asked who is calling.
  3. 403: the server knows the caller but will not let it into the admin area.
  4. 404: nothing found at that address. In a real file, this line would contain the caller's network address too.
  5. 429: the caller sent too many requests in a short time.
  6. 500: the server hit an unexpected fault. Check what the reply showed the caller.

Why this is risky: one caller hitting 403, 404 and 429 in a few seconds may be probing the service.

The safer way: watch for patterns like this and keep every error reply short and generic.

How does it work?

  1. The request arrives. It names a path, such as /reports, and may carry credentials.
  2. The server checks who is asking. If the credentials are missing or not valid, it should answer 401. A 401 reply must also say how to prove who you are [1].
  3. The server checks what they may do. If the caller is known but not allowed, it answers 403. The standard says the server understood the request but refuses it [1].
  4. The server checks the pace. If one caller sends too many requests in a given time, it can answer 429. That reply may say how long to wait [2].
  5. The server does the work. If all goes well, it answers 200. If it hits an unexpected fault, it answers 500 [1].
Diagram titled How a server picks a security-related status code. Four boxes in a row joined by arrows. Box 1, No valid pass?: missing or rejected credentials gives 401 Unauthorized, meaning who are you? Box 2, Not allowed?: the server knows the caller but the answer is no, giving 403 Forbidden. Box 3, Too many?: too many requests in a short time gives 429 Too Many Requests. Box 4, Server broke?: an unexpected fault on the server gives 500 Internal Error, keep details private. A note says a server may send 404 Not Found instead of 403 to hide that something exists, and error pages should stay short and generic, with full details kept in the server's own logs.
Figure 1. The main security checks a server makes, and the code each one sends back.

A server does not always want to admit that something exists. The standard lets it answer 404 Not Found instead of 403, which hides the page from callers who should not know about it [1].

Error pages need care too. OWASP warns that unhandled errors can reveal software names and versions, which helps attackers in their early research [3]. It suggests one central error handler that logs the details and sends back a generic reply [3].

A worked example

This story is made up to show the idea.

Kofi Hollis looks after a small online shop's systems. Each morning he skims a dashboard of status codes from the shop's API.

One Monday he sees a sharp rise in 401 replies overnight. They all come from one network address and target the API used by delivery partners.

Kofi checks the shop's list of partner keys. None of them match the failed attempts. It looks like someone is guessing keys, so he blocks the address and tells the team.

Later that day, a tester, Kofi Iyer, reports something else. A broken search sends back a 500 error page with a long technical trace. It names the database and the framework version.

The developers add a central error handler. Now a fault sends back a short message and a reference number, while the full trace goes to the private logs.

They also add a limit on requests per caller. Callers who go over it get 429 replies, and the dashboard shows them.

The following week, the dashboard shows a few callers hitting the new limit. Kofi checks them, and they turn out to be a partner script stuck in a loop.

Kofi learned that status codes are a quick health check. Rising 401s pointed to guessing, and a chatty 500 page showed details that should have stayed private.

Myths and mistakes

What people thinkWhat is true
401 Unauthorized is about permissions.Despite its name, 401 is about missing or invalid credentials[1]. A known caller who lacks permission should get 403.
403 means "log in and try again".The standard says the client should not simply repeat the request with the same credentials[1].
A detailed 500 page helps everyone.It helps attackers too. Keep details in logs and send a generic reply[3].
A 200 OK means the access check passed.200 only says the server did the work. If the access check is missing, it will still say 200.
404 always means the page does not exist.A server may use 404 to hide a page the caller is not allowed to know about[1].

What can I do this week?

  • Open your web or API logs and count the 401, 403, 429 and 500 replies for one day.
  • Try a private page with no credentials in a test system. Note which code you get.
  • Cause an error on purpose in a test system and read what the reply reveals.
  • Read Authentication vs Authorisation for Beginners to fix the 401 and 403 difference in your mind.

Checklist

  • I can name the five status code families by their first digit.
  • I know 401 is about proving who you are, and 403 is about what you may do.
  • I check that private pages refuse callers with no credentials.
  • I keep error replies short and generic.
  • I keep full error details in private logs.
  • I watch for spikes in 401, 403 and 429 replies.
  • I do not treat a 200 OK as proof that access checks ran.

Common questions

What is the difference between 401 and 403?

401 means the server did not get valid credentials, so it does not know who is asking. 403 means the server understood the request but refuses it, often because the caller lacks permission. In short, 401 is about identity and 403 is about access.

Why would a site show 404 when the page exists?

Sometimes a server hides a page from callers who are not allowed to see it. The HTTP standard lets a server answer 404 instead of 403 for this reason. It stops outsiders learning which private pages exist.

Is a 500 error a security problem?

Not always, since it just means the server hit an unexpected fault. It becomes a problem when the error page shows internal details such as software versions or code traces. Those details belong in private logs.

What does 429 Too Many Requests mean?

It means the caller sent too many requests in a given time. The reply may include a Retry-After header saying how long to wait[2]. Servers use it to slow down floods of requests, including password or key guessing.

Do apps and scripts get status codes too?

Yes. Software that calls an API, such as a service account or an AI agent, gets the same codes. A run of 401s from a script can mean its key has expired or been revoked, which is worth checking.

Where next?

Ready for the detail? Read the practitioner guide: API Security Guide. It covers how APIs check identity and access, and how to test and monitor them.

Also useful:

Related NHI Mgmt Group resources: Broken Access Control Prevention Guide, Rate Limiting and API Abuse Guide and Authentication vs Authorisation.

Key terms

HTTP status codes
Three-digit numbers a web server sends to say how a request went.
401 Unauthorized
A reply meaning the request lacked valid credentials, so the server does not know who is asking.
403 Forbidden
A reply meaning the server understood the request but refuses to carry it out.
429 Too Many Requests
A reply meaning the caller sent too many requests in a given time.
Authentication
Checking who a person or piece of software is.
Authorisation
Deciding what a known person or piece of software is allowed to do.
Verbose error messages
Error replies that reveal internal details, such as code traces or software versions.

Sources and further reading

  1. IETF, "RFC 9110: HTTP Semantics", Section 15 (Status Codes), June 2022. https://www.rfc-editor.org/rfc/rfc9110.html (accessed 1 Dec 2026).
  2. IETF, "RFC 6585: Additional HTTP Status Codes", Section 4 (429 Too Many Requests), April 2012. https://www.rfc-editor.org/rfc/rfc6585.html (accessed 1 Dec 2026).
  3. OWASP, "Error Handling Cheat Sheet", OWASP Cheat Sheet Series. https://cheatsheetseries.owasp.org/cheatsheets/Error_Handling_Cheat_Sheet.html (accessed 1 Dec 2026).

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.