# HTTP 401 Unauthorized

> A 401 means the request lacks valid credentials for the resource. Learn the WWW-Authenticate challenge, how it differs from 403, and how to fix it.

Canonical: https://scaplet.com/errors/http/401

Guide Error · HTTP status codes

A 401 means the request lacks valid credentials for the resource. Learn the WWW-Authenticate challenge, how it differs from 403, and how to fix it.

5 min

read

7

sources

Oct 22, 2026

updated

Scaplet Editorial Team

author

401 4xx · Client error

The short answer

HTTP 401 Unauthorized means the request has not been applied because it lacks valid authentication credentials for the target resource. The server must send a WWW-Authenticate header naming how to authenticate. Fix it by sending valid credentials in an Authorization header. If you already did, the server refused them. If you are signed in and still blocked, you are probably looking at a 403.

1. [What does 401 Unauthorized mean?](#what-does-401-unauthorized-mean)
2. [The challenge and response flow](#the-challenge-and-response-flow)
3. [How to fix a 401 as a user](#how-to-fix-a-401-as-a-user)
4. [How to fix a 401 as a developer or site owner](#how-to-fix-a-401-as-a-developer-or-site-owner)
5. [What it does to SEO](#what-it-does-to-seo)

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F401%20(%22HTTP%20401%20Unauthorized%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F401%20(%22HTTP%20401%20Unauthorized%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F401%20(%22HTTP%20401%20Unauthorized%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F401%20(%22HTTP%20401%20Unauthorized%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

_01_401 compared with 403 and 407

## What does 401 Unauthorized mean?

RFC 9110 says the 401 [status code](/glossary/http-status-codes) indicates that the request has not been applied because it lacks valid authentication credentials for the target resource. The server generating a 401 must send a WWW-Authenticate header containing at least one challenge applicable to the resource. MDN adds that the header describes the authentication scheme the server expects the client to use.

### Who is asking for credentials

401 Unauthorized

The server hosting the resource

403 Forbidden

Nobody; the server refuses

407 Proxy Authentication Required

A proxy between client and server

### Challenge header

401 Unauthorized

WWW-Authenticate

403 Forbidden

None required

407 Proxy Authentication Required

Proxy-Authenticate

### Credentials header

401 Unauthorized

Authorization

403 Forbidden

Not applicable

407 Proxy Authentication Required

Proxy-Authorization

### Does re-authenticating help?

401 Unauthorized

Yes

403 Forbidden

Usually no

407 Proxy Authentication Required

Yes, with proxy credentials

The name is misleading. The status is called Unauthorized, but it is about authentication: the server does not know who you are, or does not accept the proof you gave. If the request did include credentials, the 401 indicates that authorization has been refused for those credentials, and the client may repeat the request with a new or replaced Authorization header.

See [403 Forbidden](/errors/http/403) for the refusal case and [407 Proxy Authentication Required](/errors/http/407) for the proxy version. The wider family is in [HTTP status codes](/glossary/http-status-codes).

**The 401 and 403 rule of thumb from MDN**If a server receives invalid credentials it should respond with 401 (or 407 for a proxy). If it receives valid credentials that are inadequate for the resource, it should respond with 403, and browsers will not propose a new attempt.

_02_How it works

## The challenge and response flow

A 401 response as MDN shows it

```
HTTP/1.1 401 Unauthorized Date: Tue, 02 Jul 2024 12:18:47 GMT WWW-Authenticate: Bearer
```

Common schemes in MDN's list include Basic (RFC 7617), Bearer (RFC 6750, bearer [tokens](/glossary/tokenization) for OAuth 2.0-protected resources) and Digest (RFC 7616). Basic sends credentials base64-encoded, not encrypted, so use it only over [HTTPS](/glossary/https).

1. 01

### Request without credentials

The client asks for a protected URL with no Authorization header.
2. 02

### Server challenges

It answers 401 with a WWW-Authenticate header, for example WWW-Authenticate: Bearer or WWW-Authenticate: Basic realm="Access to the staging site".
3. 03

### Client retries with credentials

The client repeats the request with an Authorization header, whose format depends on the scheme: Authorization: <type> <credentials>. Browsers usually show a password prompt first.
4. 04

### Server decides

Valid credentials get the resource. Invalid ones get another 401. Valid credentials without enough rights get a 403.

_03_Checklist

## How to fix a 401 as a user

1. 01 Sign in, or sign in again. Expired or wrong credentials are the plainest cause.
2. 02 Check that you're using the account the resource belongs to. An account that is valid but not allowed would get a 403 instead.
3. 03 Don't repeat a request with the same wrong credentials; a client that already tried and gets the same challenge should show the response to you, since RFC 9110 says it usually carries relevant diagnostic information.
4. 04 If you don't have an account, ask the site owner. A 401 on a page with no login option usually means the page is meant to be private.

_04_401 causes and where to look

## How to fix a 401 as a developer or site owner

Cause

### No Authorization header sent

Check

Inspect the request in the browser Network panel or with curl -v

Fix

Send the header the WWW-Authenticate challenge asks for

Cause

### Wrong scheme

Check

Compare the scheme in WWW-Authenticate with the one you sent (Basic, Bearer, Digest)

Fix

Use the scheme and format the server names

Cause

### Expired or revoked token

Check

Token expiry and server logs

Fix

Obtain a new token and retry

Cause

### Wrong password file entry (Basic)

Check

Server config: auth_basic and the password file in nginx, or .htaccess and .htpasswd in Apache

Fix

Correct the entry in the password file

Cause

### Header stripped by a proxy or CDN

Check

Compare the request at the client with the request the origin logs

Fix

Configure the intermediary to forward the Authorization header

Cause

### Server returns 401 without WWW-Authenticate

Check

Response headers

Fix

Add a challenge; RFC 9110 says a 401 must include one

Send Basic and Bearer credentials with curl

```
# Basic curl -i -u user:password https://example.com/admin # Bearer token curl -i -H "Authorization: Bearer $TOKEN" https://example.com/api/me
```

In nginx, the auth_basic module answers with a 401 and a WWW-Authenticate: Basic challenge when credentials are missing or wrong (see ngx_http_auth_basic_module.c in nginx's source). The module's own docs give this example:

Basic authentication in nginx

```
location / { auth_basic "closed site"; auth_basic_user_file conf/htpasswd; }
```

The parameter of auth_basic is used as the realm. For a 403 where you expected a 401 in nginx, see [403 in nginx](/errors/http/403/nginx).

**Never send Basic credentials over plain HTTP**MDN warns that Basic credentials are base64 encoded, a reversible encoding, so anyone who can see the traffic can read them. Use HTTPS with it.

_05_Explained

## What it does to SEO

Google lists 401 among the 4xx codes it handles alike (except 429): the content is treated as not existing, and an indexed URL is removed from the index. It also says 401 and 403 have no effect on crawl rate. Google doesn't index URLs that return a 4xx status code, so a login-gated page that returns 401 stays out of search, and a public page that returns 401 to [Googlebot](/ai-crawlers/googlebot) will drop out. See [4xx errors](/seo-issues/4xx-errors) and Google's page on how HTTP status codes affect its crawlers.

Questions

## Asked a lot.

4 questions people ask next, answered from the sources on this page.

_01_ What is the difference between 401 and 403?

A 401 says the request lacks valid authentication credentials and must carry a WWW-Authenticate challenge, so new credentials can work. A 403 says the server understood the request and refuses it; MDN says authenticating or re-authenticating makes no difference.

_02_ What is HTTP authentication?

A framework in which the server challenges a request with 401 and a WWW-Authenticate header, and the client answers with an Authorization header. MDN notes the exchange is the same for most schemes, though the header contents differ.

_03_ Why do I keep getting a 401 error?

The server is not accepting the credentials sent. Check that the Authorization header is present, that its scheme matches the challenge, that the token hasn't expired, and that no proxy is stripping the header.

_04_ What does error code 401 mean on a website?

The page needs you to sign in or the credentials you gave were rejected. If you are signed in and still blocked, expect a 403 instead, which signing in again won't fix.

Sources · 7

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- rfc-editor.org
- mozilla.org
- nginx.org
- github.com
- curl.se
- google.com

1. 01 [RFC 9110: HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html) rfc-editor.org · checked 2026-10-25
2. 02 [401 Unauthorized - HTTP - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/401) developer.mozilla.org · checked 2026-10-25
3. 03 [HTTP authentication - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Authentication) developer.mozilla.org · checked 2026-10-25
4. 04 [Module ngx_http_auth_basic_module - nginx documentation](https://nginx.org/en/docs/http/ngx_http_auth_basic_module.html) nginx.org · checked 2026-10-25
5. 05 [nginx source: ngx_http_auth_basic_module.c (GitHub)](https://github.com/nginx/nginx/blob/master/src/http/modules/ngx_http_auth_basic_module.c) github.com · checked 2026-10-25
6. 06 [curl man page](https://curl.se/docs/manpage.html) curl.se · checked 2026-10-25
7. 07 [How HTTP status codes affect Google's crawlers](https://developers.google.com/crawling/docs/troubleshooting/http-status-codes) developers.google.com · checked 2026-10-25

## Keep learning

[All errors](/errors)

[Learn 403 Forbidden HTTP status codes](/errors/http/403) [Related 4xx errors Status codes and links](/seo-issues/4xx-errors) [Read next HTTP 407 Proxy Authentication Required HTTP status codes](/errors/http/407) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 401 errors
[401 Unauthorized in IIS](/errors/http/401/iis) [401 Unauthorized in Laravel](/errors/http/401/laravel) [401 Unauthorized in Spring Boot](/errors/http/401/spring-boot) [401 Unauthorized in the WordPress REST API](/errors/http/401/wordpress)

Nearby in errors
[400 Bad Request in nginx](/errors/http/400/nginx) [400 Bad Request in Spring Boot](/errors/http/400/spring-boot)

More in HTTP status codes
[5xx errors](/errors/http/5xx-errors) [HTTP 200 OK](/errors/http/200) [HTTP 201 Created](/errors/http/201) [HTTP 204 No Content](/errors/http/204) [HTTP 206 Partial Content](/errors/http/206) [HTTP 301 Moved Permanently](/errors/http/301) [HTTP 302 Found](/errors/http/302) [HTTP 303 See Other](/errors/http/303) [HTTP 304 Not Modified](/errors/http/304) [HTTP 307 Temporary Redirect](/errors/http/307) [HTTP 308 Permanent Redirect](/errors/http/308) [HTTP 400 Bad Request](/errors/http/400) [HTTP 401 Unauthorized](/errors/http/401) [HTTP 405 Method Not Allowed](/errors/http/405) [HTTP 407 Proxy Authentication Required](/errors/http/407) [HTTP 408 Request Timeout](/errors/http/408) [HTTP 409 Conflict](/errors/http/409) [HTTP 412 Precondition Failed](/errors/http/412) [HTTP 431 Request Header Fields Too Large](/errors/http/431) [HTTP 499 Client Closed Request](/errors/http/499) [HTTP 500 Internal Server Error](/errors/http/500) [HTTP 501 Not Implemented](/errors/http/501) [HTTP redirect codes](/errors/http/http-redirect-codes) [HTTP status code list](/errors/http/http-status-code-list)

Terms on this page
[HTTP status codes](/glossary/http-status-codes) [Tokenization](/glossary/tokenization) [HTTPS](/glossary/https)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
