401 Unauthorized

401 Unauthorized

When you encounter the HTTP 401 Unauthorized status code, it means the server is asking you to provide valid login credentials before accessing the requested resource.

You can Check Your URLs HTTP Code for FREE

Introduction
In Action
Sample
Conclusion

Introduction

When you encounter the HTTP 401 Unauthorized status code, it means the server is asking you to provide valid login credentials before accessing the requested resource.

It’s like a locked door that requires the right key (username and password) to enter. If you see this error, make sure to provide the correct login information to gain access.

In Action

When you encounter the HTTP 401 Unauthorized error, it means you need to provide valid login credentials before accessing the requested resource. You might need to log in or include your credentials in the HTTP request.

Remember, this is different from the 403 Forbidden error, which indicates that the action you’re trying to perform is not allowed.

When the server sends a 401 response, it will also include the WWW-Authenticate header, specifying the authentication methods it allows.

Some common authentication schemes include Basic, Bearer, Digest, HOBA, Mutual, and AWS4-HMAC-SHA256. Make sure to follow the server’s instructions and provide the correct credentials to gain access to the resource.

Sample

In this scenario, the client tries to access a protected resource, and the server sends back a 401 Unauthorized status code, indicating that authentication is required. The server also mentions that it supports basic and mutual authorization.

To gain access, the client sends a username:password pair using basic authentication in the Authorization header. Once the server verifies the credentials, it allows the client to access the requested resource.

Initial request

GET /documents/tech-news HTTP/1.1
Host: www.example.com

Initial response

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic; realm=”Documents”
WWW-Authenticate: Mutual

Next request, including Authorization

GET /documents/tech-news HTTP/1.1
Host: www.example.com
Authorization: Basic RXhhbXBsZTphaQ==

Final response

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 25000

< PDF document included in message body>

Conclusion

In conclusion, the 401 Unauthorized status code indicates that the client’s request lacks valid authentication credentials to access a protected resource. The server requires the client to provide valid login credentials or authentication information before granting access to the requested resource.

Related articles

999 Request Denied

999 Request Denied The 999 HTTP response status code is...

599 Network Connect Timeout Error

599 Network Connect Timeout Error The 599 HTTP response status...

598 Network read timeout error

598 Network read timeout error The 598 HTTP response status...

561 Unauthorized

561 Unauthorized The 561 HTTP response status code means there...

530 Site Frozen

530 Site Frozen The 530 HTTP response status code is...

999 Request Denied

0
999 Request Denied The 999 HTTP response status code is an unofficial catch-all error code returned...

599 Network Connect Timeout Error

0
599 Network Connect Timeout Error The 599 HTTP response status code indicates a timeout when trying...

598 Network read timeout error

0
598 Network read timeout error The 598 HTTP response status code indicates a timeout occurred during...

561 Unauthorized

0
561 Unauthorized The 561 HTTP response status code means there was an authentication failure. You can Check...

530 Site Frozen

0
530 Site Frozen The 530 HTTP response status code is a specialized server error used by...