dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Home/Error Library/sqlserver-18456-login-failed
SQL Server
SQL Server 2019 / 2022Authentication & Security
5 min read
Error 18456: Login failed for user

SQL Server Error 18456: "Login failed" — What the State Code Actually Means

In Error 18456, the State code reveals the actual root cause. Specific fixes for State 5, 8, 11, 18, 38, and 40, with ERRORLOG extraction scripts.

Reviewed by:Senior Database Architect & SRE (dataiotech Labs)
Tested Versions: SQL Server 2019 / 2022
First 60 Seconds Emergency Protocol:

The error string is a symptom, not the root cause. Do not restart the server blindly. Run the diagnostic queries below to pinpoint the actual failure mode.

▸Symptom

plaintext
Login failed for user 'app'. Reason: Password did not match that for the login provided.

The critical detail is the internal State number stored in ERRORLOG:

  • •State 5: Login does not exist.
  • •State 8: Password mismatch or server configured for Windows Auth only.
  • •State 11/12: Login is disabled or server access denied.
  • •State 38/40: Default database unavailable or offline.

▸Diagnostics

sql
EXEC xp_readerrorlog 0, 1, N'18456'; SELECT SERVERPROPERTY('IsIntegratedSecurityOnly') AS windows_only_mode;

Other Database Error Triage Playbooks

Other battle-tested diagnostic guides for high-severity database errors.

All Errors (20)