SSPI Handshake Failed in SQL Server (Error 17806)

🚨Part of the SQL Server Errors series, the exact messages and what actually causes them.In: Security

Windows authentication reached SQL Server and Windows refused the account before any login was checked. The error log gets 17806, the client usually gets 18452, and no SQL Server setting will fix it.

Error 17806  ·  Severity 20  ·  State 14
SSPI handshake failed with error code 0x8009030c, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext failed. The operating system error code indicates the cause of failure. The logon attempt failed [CLIENT: 127.0.0.1]
⚡Read the 17806 line first. The hex code after error code names the failure (decode it). The client’s message tells you which side failed (what the client saw). Then work the cause the code points to: the account, the domain controller or Kerberos.

Read the 17806 Line First

17806 is written to the error log only; the client never receives it. Search the current log, and change the first 0 to 1, 2 and so on for older ones:

EXEC sys.xp_readerrorlog 0, 1, N'SSPI handshake';

Each failed attempt writes 4 lines: the 17806 pair, then an 18452 pair for the same client. The IP in [CLIENT: ...] is the machine that tried to connect.

ERRORLOG on the lab instance, a Windows account the server cannot validateexample output, not something to copy
Logon Error: 17806, Severity: 20, State: 14. Logon SSPI handshake failed with error code 0x8009030c, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext failed. The operating system error code indicates the cause of failure. The logon attempt failed [CLIENT: 127.0.0.1] Logon Error: 18452, Severity: 14, State: 1. Logon Login failed. The login is from an untrusted domain and cannot be used with Integrated authentication. [CLIENT: 127.0.0.1]

The hex code is a Windows security status. These are the 3 you will meet, in Windows’ own words from the security error code list on MS Docs:

MS Docs has no error page for 17806 and publishes no meaning for its states, so act on the hex code, not the state number.


What the Client Saw

The client gets a different message, and which one tells you where the failure happened:

  • Login failed. The login is from an untrusted domain (error 18452). This is the same failure seen from the client: the attempt that wrote the 17806 above got exactly this. The account does not have to come from another domain, the server simply could not validate it, which MS Docs lists as an unrecognized Windows principal. More in Untrusted Domain (18452).
  • Cannot generate SSPI context. The client gave up before the server judged anything, so there is no 17806 to find. That is usually an SPN or name resolution problem, covered in Kerberos vs NTLM and the Cannot generate SSPI context guide on MS Docs.
  • Login failed for user ‘DOMAIN\name’ (error 18456). Authentication worked and the server has no login for that account. That is Login Failed (18456), not this post.
sqlcmd on the lab instance, the same attempt as the error log aboveexample output, not something to copy
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Login failed. The login is from an untrusted domain and cannot be used with Integrated authentication..

An application on System.Data.SqlClient gets the same text as a SqlException with Number 18452, Class 14, State 1.


The Account Cannot Log On to the Server

This is what 0x8009030c means: the SQL Server machine was handed an account that Windows would not log on. The usual reasons, documented rather than reproduced here:

  • The account’s password is wrong or was changed, or the account is locked out, disabled or expired.
  • The account lacks the Access this computer from the network right on the SQL Server machine. Microsoft’s support team worked exactly this 17806 and 18452 pair to that cause and fixed it by granting the right (their write-up on MS Docs).
  • The account belongs to a domain the server’s domain does not trust, or to another forest. MS Docs says the same forest is required for SSPI to work.

Windows records which one it was. On the SQL Server machine, open the Security log in Event Viewer, filter on event 4625 at the time of the 17806, and read Status and Sub Status. Failed logons only appear there when logon failure auditing is on.

  • 0xC000006A, bad password.
  • 0xC0000064, the account name does not exist.
  • 0xC0000234, locked out. 0xC0000072, disabled. 0xC0000193, expired.
  • 0xC000015B, the logon right is missing.

The Server Cannot Reach the Domain

0x80090311 means no domain controller could be reached to validate the account. Documented, not reproduced here, because this lab has no domain. Run this in Windows PowerShell on the SQL Server machine, then on the client:

Test-ComputerSecureChannel

False means that machine’s own trust with the domain is broken, and MS Docs gives -Repair to restore it. If the client sits in a different domain, check the trust between the two domains next.


Check Kerberos: Clock, SPN and DNS

Documented, not reproduced here, because a machine with no domain never uses Kerberos. Cheapest check first:

  • Clock. The default domain policy lets Kerberos tolerate 5 minutes of clock difference. Compare w32tm /query /status on the client and the server.
  • Duplicate SPN. setspn -X searches for duplicates and setspn -L <service account> lists what the account holds (setspn on MS Docs). A missing SPN usually falls back to NTLM quietly; a duplicate breaks Kerberos.
  • DNS. ping -a <server IP> from the client must return the server’s correct full name. A wrong or stale record sends the client to an SPN that does not match.
  • The SQL Server service account. Locked out, or its password changed without the service being restarted. MS Docs names both.

SPN registration in full, and registering a missing one, is in Kerberos vs NTLM.


How Working Connections Authenticate

Ask the server how the connections that did get in authenticated:

SELECT auth_scheme, net_transport, COUNT(*) AS connections
FROM sys.dm_exec_connections
GROUP BY auth_scheme, net_transport;
The query on the lab instanceexample output, not something to copy
auth_scheme net_transport connections ----------- ------------- ----------- NTLM TCP 10

A machine with no domain shows NTLM for everything, and MS Docs says a connection from the same machine always uses NTLM. NTLM where you expected Kerberos is Kerberos failing quietly. 17806 is the loud version: the server refused the attempt outright.

Asking an AI assistant? Give it the whole 17806 line and this output. With the sqldba MCP server connected it can pull the verified 17806 and 18452 write-ups itself instead of answering from memory.


Frequently Asked Questions

Is “Cannot generate SSPI context” the same problem?
No. That one fails on the client before the server judges anything, so the error log has no 17806 for it. On the lab machine, which has no domain, connecting with Windows authentication by IP address gave it every time: tcp:127.0.0.1 failed with The message supplied for verification is out of sequence and the machine’s own IP with No credentials are available in the security package, each followed by Cannot generate SSPI context, and neither wrote a line to the error log. The host name connected with NTLM. Connect by name, then work through the MS Docs guide.
It worked yesterday. What changes overnight?
A clock drifting past the 5 minute Kerberos tolerance, a password change or lockout on the account that connects, a machine’s secure channel with the domain breaking, or a DNS change. All of them are outside SQL Server, which is why nothing on the instance changed.
Does restarting SQL Server fix it?
Occasionally, and misleadingly. At startup SQL Server tries to register its own SPN, which works when the service account has read and write servicePrincipalName rights (MS Docs). If a restart fixes it, the real problem is SPN registration, and it will be back.
Does a SQL login get the same error, or is it only Windows accounts?
Only Windows accounts, and that is the fastest test you have. SSPI is the Windows authentication handshake, so a SQL authentication login never touches it. If a SQL login connects to the same instance from the same machine at the same moment, the engine, the network path and the port are all fine, and the problem is the account, the domain or Kerberos. If the SQL login fails too, stop investigating SSPI and treat it as an ordinary connectivity or login failure.

Where To Go Next

This error sits between the network and the login. The neighbours on either side:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *