Fix it now
A 401 from IIS is three different failures wearing one status code, and the sub-status separates them. Microsoft publishes 401.1 as a failed logon, 401.2 as a logon that failed because of server configuration, and 401.3 as unauthorized due to the ACL on the resource. Until you know which one you have, every change is a guess.
%windir%\system32\inetsrv\appcmd list config "Default Web Site/" /section:system.webServer/security/authentication
setspn -L <account the pool runs as>
setspn -X
- Open the IIS log for the site and read sc-status and sc-substatus together on the failing request. The sub-status is the diagnosis; the rest of this is confirmation.
- For 401.3, grant Read on the content folder to the identity that actually authenticated: the anonymous user for anonymous requests, the caller for Windows-authenticated ones, or the application pool identity where the site is set to use it.
- For 401.2, check which authentication methods are enabled on the site in IIS Manager under Authentication, and confirm the role service for the one you need is installed.
- For 401.1, test the same account interactively on another machine to rule out a wrong password, a lockout, an expired password or a disabled account.
- If it works on the server console and fails from every client, look at Kerberos:
setspn -Lon the pool account, thensetspn -Xfor duplicates across the domain.
The first 401 on a Windows-authenticated request is normal. It is the challenge. Look at the last status on the connection, not the first.
If the site now serves the page without prompting, you can stop here. If it still prompts, the next section explains which side of the handshake is failing.
Why it happens
Authentication in IIS is a negotiation. The first request arrives with no credentials, IIS answers 401 with a list of the schemes it accepts, and the client picks one and tries again. That first 401 appears in the log on every successful Windows-authenticated request. The one worth investigating is the last one, where the client had nothing left to try.
401.1 and 401.2 fail on opposite sides of that exchange. Microsoft publishes 401.1 as “Logon failed”: a credential reached the local security authority and was refused, so you are looking at the account rather than at IIS. 401.2 is published as “Logon failed due to server configuration”: the negotiation never got that far, because the client could not use any scheme the site offered, or the scheme it needed was disabled, or anonymous is off and nothing else is on.
401.3 is a different layer entirely. Microsoft publishes it as “Unauthorized due to ACL on resource”. Authentication succeeded, IIS tried to open the file as the resulting identity, and the file system said no. Which identity that is depends on how the request authenticated, and that is the part people get wrong: the anonymous account for anonymous requests, the caller for Windows-authenticated ones, or the pool identity where the site is configured to use it.
Anonymous authentication is enabled and quietly winning
You have this one if The application behaves as though nobody is signed in, or a 401.3 names an identity you did not expect.
- In IIS Manager select the site, open Authentication, and read which methods show as Enabled.
- Disable Anonymous Authentication if the site is meant to identify its users.
- If anonymous must stay on, open its settings and decide deliberately whether it runs as a specific user or as the application pool identity.
- Grant Read on the content to whichever identity you chose, then retry.
Anonymous and Windows authentication coexist happily, and anonymous is tried first. Leaving both on is the most common reason a site never sees a real user name.
The ACL does not include the identity that authenticated
You have this one if A 401.3, and the folder’s Security tab has no entry covering the caller, the anonymous account or the pool.
- Work out which identity is in play from the site’s Authentication settings before you touch permissions.
- Grant Read, and only Read, on the content directory to that identity.
- For an application pool identity, use the
IIS AppPool\<poolname>form. It is a real security principal even though it never appears in Active Directory. - If content is on a share, both the share permissions and the NTFS permissions have to allow the read.
Do not grant Everyone. It hides which identity is really being used, and the next time this happens you will have removed the only evidence.
Kerberos cannot identify the service
You have this one if Authentication works from the server console and fails from every client, or works over NTLM and fails as soon as Kerberos is used.
- List the service principal names on the account the pool runs as:
setspn -L <account> - Search the domain for duplicates:
setspn -X. A duplicate breaks Kerberos for every service that shares it. - Register the missing name against the correct account with
setspn -S, which checks for duplicates before it writes. - If kernel-mode authentication is on and the pool runs as a domain account, either set the site to use the pool credentials for kernel-mode authentication, or register the name against the machine account instead.
Microsoft documents setspn -S rather than -A precisely because it refuses to create a duplicate. Use it.
The next fix edits the registry. Export the key first. The loopback check exists to block a real class of relay attack, and Microsoft states that disabling it outright reduces security and opens the server to NTLM man-in-the-middle attacks.
The loopback check rejects name-based requests on the server itself
You have this one if Browsing the site on the server works by machine name and fails with a DNS alias or a load balancer name. Remote clients are fine. You get repeated logon prompts, an access denied message, or “No network provider accepted the given network path”.
- Add the names clients use to the multi-string value
BackConnectionHostNamesunderHKLM\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0, one host name per line. - If a value of that name already exists as a REG_DWORD, delete it first. Microsoft documents that step explicitly.
- Restart the server so the new list is read, then re-test using the alias from the console.
There is a blanket switch, DisableLoopbackCheck under the Lsa key. Microsoft documents it as the second method and warns about it. Prefer the host-name list.
Full reference
The five sub-statuses, as Microsoft publishes them
| Sub-status | Published meaning | What that makes it |
|---|---|---|
401.1 |
Logon failed | An account problem: password, lockout, expiry, or an account the server does not trust |
401.2 |
Logon failed due to server configuration | A negotiation problem: the client and the site have no scheme in common |
401.3 |
Unauthorized due to ACL on resource | A file system problem, after authentication already succeeded |
401.4 |
Authorization failed by filter | A filter in the pipeline made the decision |
401.5 |
Authorization failed by ISAPI/CGI application | An ISAPI or CGI application made the decision |
Working out which identity a request is running as
This is the single most useful habit for 401.3, because the answer is not always the one on the login page.
- Open the site’s Authentication settings in IIS Manager and note every method that is Enabled.
- If Anonymous is enabled, open its settings. It runs either as a named account or as the application pool identity, and that choice decides which ACL matters.
- If Windows Authentication is enabled and anonymous is not, the identity is the caller.
- If the application impersonates, or the pool is configured to run as a specific domain account, that account is the one to check against the folder.
- Grant Read to whichever identity that turned out to be, and re-test with a second account in a different group so you know you fixed the model rather than one user.
The two loopback registry values
| Value | Path | Type | What Microsoft says |
|---|---|---|---|
BackConnectionHostNames |
HKLM\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0 |
REG_MULTI_SZ | The recommended method. One CNAME or DNS alias per line |
DisableLoopbackCheck |
HKLM\SYSTEM\CurrentControlSet\Control\Lsa |
DWORD | Set to 1 it turns the check off entirely. Documented, with the warning that it reduces security and opens the server to NTLM man-in-the-middle attacks |
If BackConnectionHostNames already exists as a REG_DWORD rather than a multi-string, delete it before creating the correct one. Microsoft calls that out because it is a common leftover and the value is silently ignored in the wrong type.
Service principal names, in the order that saves time
| Command | What Microsoft publishes it as |
|---|---|
setspn -L <account> |
Lists the currently registered SPNs for the computer or account |
setspn -X |
Performs a search for duplicate SPNs |
setspn -Q <spn> |
Queries for any existing SPNs |
setspn -S <spn> <account> |
Adds the SPN after verifying that no duplicates exist |
Microsoft documents -S and mentions -A only to say you should use -S instead, because it checks for duplicates first. A duplicate SPN breaks Kerberos for both holders, not only the one you are troubleshooting, so removing the wrong registration is the fix rather than adding another.
Where to look when the sub-status does not settle it
- Read the last status on the connection. A 401 followed by a 200 is a successful Windows-authenticated request and nothing is wrong.
- Test from the console and from a workstation and compare. The difference between them is itself the clue, and it usually points at Kerberos or at the loopback check.
- For a 401.4 or 401.5, identify the filter or ISAPI application in the pipeline and take the question to whoever owns it. IIS is reporting somebody else’s decision.
- Check whether the site is behind something that terminates the connection first. A load balancer or reverse proxy changes which name the client presents, which is exactly what the loopback check reacts to.
Every code this article covers
| Code | What it points at | Source |
|---|---|---|
HTTP 401.1 |
Logon failed: credentials were supplied and the logon attempt was refused | Microsoft Learn |
HTTP 401.2 |
Logon failed due to server configuration: no authentication method was available that both the client and the site could use | Microsoft Learn |
HTTP 401.3 |
Unauthorized due to ACL on resource: authentication succeeded and the access control list on the content denied the read | Microsoft Learn |
HTTP 401.4 |
Authorization failed by filter: a filter in the request pipeline rejected the request | Microsoft Learn |
HTTP 401.5 |
Authorization failed by ISAPI/CGI application: the component made the decision, not IIS | Microsoft Learn |
Confirm the fix worked
- Request the protected URL from a client workstation and confirm it returns content without prompting repeatedly.
- Check the IIS log for that request and confirm the final entry is a 200 with sc-substatus 0.
- Confirm the application reports the expected user name rather than the anonymous account.
- Test with a second account in a different group, so you know the permission model is right rather than one entry.
- If you edited the Lsa keys, restart the server and re-test by alias, because the list is read at startup.
Questions people ask about this
Is any of this a licensing problem?
No. These are authentication settings, file system permissions and directory configuration. Everything you need is already on the server.
Why do I see a 401 in the log on requests that clearly worked?
Because the first 401 is the challenge. The client sends an unauthenticated request, gets challenged, and retries with credentials. Read the last status on the connection, not the first.
Should I just give Everyone read access to fix a 401.3?
No. It masks which identity is really being used and publishes content you may not intend to. Microsoft’s published meaning for 401.3 is the ACL on the resource, so identify the account from the Authentication settings and grant Read to that one.
Why does it work on the server but not from a workstation?
That pattern is usually Kerberos. From the console the request can fall back to a local logon; from a workstation it needs a correctly registered service principal name on the account the pool runs as. Check setspn -L and then setspn -X.
Is BackConnectionHostNames or DisableLoopbackCheck the right answer?
BackConnectionHostNames. Microsoft marks it as the recommended method and attaches the security warning to the other one: disabling the loopback check entirely opens the server to NTLM man-in-the-middle attacks.
