Tech

Explainer

Updated

What does the HTTP 403 status code mean?

Key facts

Under the HTTP standard, a client should not automatically repeat the request with the same credentials, and a server may answer 404 instead to hide that a forbidden page exists.

The HTTP 403 status code, named Forbidden, means that the server understood the request but refuses to fulfill it, according to RFC 9110, the document that defines HTTP Semantics. A server that wants to say publicly why the request was forbidden can describe the reason in the response content, the standard says.

What the standard says

Section 15.5.4 of RFC 9110 defines the code in these words: "The 403 (Forbidden) status code indicates that the server understood the request but refuses to fulfill it."

The IANA HTTP Status Code Registry, which is maintained by IANA and registers status code numbers, records 403 as Forbidden with RFC 9110, Section 15.5.4, as its reference. The same registry describes the 4xx class, to which 403 belongs, as "Client Error - The request contains bad syntax or cannot be fulfilled".

RFC 9110 says that a server sending any 4xx response, except to a HEAD request, should send a representation explaining the error and whether it is a temporary or permanent condition, and that user agents should display that representation to the user.

Does logging in again fix a 403?

RFC 9110 says that if authentication credentials were provided in the request, the server considers them insufficient to grant access, and the client should not automatically repeat the request with the same credentials. The client may repeat the request with new or different credentials, but the standard adds that a request "might be forbidden for reasons unrelated to the credentials."

How 403 differs from 401

The two codes answer different problems. Under RFC 9110, 401 (Unauthorized) means the request has not been applied because it lacks valid authentication credentials for the target resource, and a server sending 401 must include a WWW-Authenticate header field with at least one challenge. The same document says that a server that receives valid credentials that are not adequate to gain access ought to respond with 403 (Forbidden).

CodeNameWhen the standard uses it
401UnauthorizedRequest lacks valid authentication credentials
403ForbiddenThe request is understood but refused
404Not FoundNo current representation, or the server will not disclose one exists

The table follows the definitions in RFC 9110, Sections 15.5.2, 15.5.4 and 15.5.5.

Why a forbidden page can show 404 instead

RFC 9110 allows an origin server that wishes to hide the current existence of a forbidden target resource to respond with 404 (Not Found) instead of 403. The standard's definition of 404 covers this case, saying the code means the origin server did not find a current representation for the target resource "or is not willing to disclose that one exists."

Which document defines HTTP status codes

RFC 9110, HTTP Semantics, is an Internet Standard of the Internet Engineering Task Force published in June 2022, and it is also known as STD 97, the IETF Datatracker shows. It obsoletes earlier documents including RFC 7231 and RFC 7235, according to the Datatracker record.

Have another question?