SQL Server Error 18456: Login Failed for User — Read the State First

Error 18456 means the SQL Server Database Engine rejected a login/authentication path, but the client message usually hides the useful reason. Do not reset a password or change authentication mode blindly. Identify the exact endpoint/instance and login, then correlate the same failed attempt with the server-side Reason and State in that instance's error log. Treat the Reason plus current Microsoft documentation as primary evidence; state numbers are diagnostic routing clues, not a timeless API contract across every version/deployment.

SQL Server · MSSQLSERVER_18456 · AuthenticationSSMS · Applications · Windows / SQL loginLast reviewed Sep 27, 2026
🎯 You’re likely in the right place if:
The client says Login failed for user '...' and reports Error 18456, or the server log records Event ID 18456.The connection reaches SQL Server far enough for the Database Engine to reject authentication.You can identify the target server/instance and the identity attempting to connect.
Choose your path from the server-side Reason / State
Only “Login failed for user” →Find the matching Reason and State before changing configuration.State 2 / 5 / 7 / 8 / 9 / 18 →Login identity, disabled login, password, or required password change.State 38 / 46 / 126 →Requested/default database, spelling, availability, mapping, or access.State 6 / 58 →Windows vs SQL authentication mismatch or related identity issue.Domain user / State 11–12 →Windows token, group permissions, and server access.ANONYMOUS LOGON / (null) →Windows authentication, Kerberos, SPN, or delegation branch.
Difficulty: ModerateSecurity-sensitive
🔎 Quick Check — capture target, login, Reason, and State

Record the exact instance, login identity, client/application, and timestamp of one failed attempt. Correlate it with the SQL Server error log.

Error: 18456, Severity: 14, State: 8. Login failed for user '<user_name>'.

Verify: You have the server-side Reason and State for the same attempt from the instance that actually received it. State 8 is documented for an incorrect password in the applicable SQL Server mapping, but always keep the accompanying Reason/version/deployment context; one state example does not make password reset the fix for every 18456.

Did the server log reveal the branch?
ADSENSE · reserved slot after the first useful step

Why the client message is not enough

SQL Server deliberately limits authentication detail returned to the client. The corresponding server log can contain the more useful Reason and State. Error 18456 is therefore a family of login/authentication failures, not one password error. Use the state table as a router only after correlating the exact log entry; Microsoft can document additional states or deployment-specific meanings over time.

Reader shortcut: if a proposed fix says “enable Mixed Mode,” “reset sa,” or “run SSMS as Administrator” before identifying the Reason/State, do not apply it yet.

Fix #1 — find the server-side Reason and State, even if you cannot log in

Reproduce one failed login at a known time. If you already have a different administrative connection, SSMS can show the current log under Management → SQL Server Logs. But do not assume SSMS access exists: Microsoft also documents the SQL Server error log as a text file that can be read directly by an authorized operating-system administrator. On Windows the default pattern is <drive>:\\Program Files\\Microsoft SQL Server\\MSSQL.<n>\\MSSQL\\LOG\\ERRORLOG; on Linux it is /var/opt/mssql/log. The actual Windows instance path can differ, so locate the active instance rather than guessing MSSQL.<n>. If you have neither SQL nor host access, give the DBA the timestamp, username, client/application, and exact target instance and ask for the matching 18456 Reason/State.

Locked out does not mean “change security first.” You do not need to enable Mixed Mode, enable sa, or grant yourself sysadmin merely to obtain the diagnostic state. Use an existing authorized admin path, direct host log access, or DBA handoff.
1
Confirm the endpoint that actually handled the attempt
Server/listener name, named instance, port when relevant, resolved node/replica, and requested database. Do not read 18456 from a different instance just because the client used the same listener name.
2
Confirm identity
SQL login, DOMAIN\user, service identity, ANONYMOUS LOGON, empty, or (null).
3
Match timestamp
Use the Reason/State from the same failed attempt, not an old 18456.

Verify: the log entry matches the same identity, timestamp/client/application and the server instance/node that actually received the attempt. Read the textual Reason together with State, then confirm the mapping against current Microsoft documentation for that deployment before changing security configuration.

Fix #2 — states 2, 5, 7, 8, 9, or 18: credentials/login branch

Microsoft maps States 2 and 5 to invalid user ID, 7 to a disabled login with incorrect password, 8 to incorrect password, 9 to invalid password, and 18 to a password that must be changed.

First prove the application reaches the intended instance and uses the identity you expect. Deployment configuration, environment settings, secret stores, or generated connection strings can override a value that looks correct elsewhere.

Keep secrets out of diagnostics: capture the server, database, authentication type, and username when safe, but never publish the password or a secret-bearing connection string.

Verify: Retest the intended account against the intended instance; the original credential-related Reason/State should be gone.

Fix #3 — states 38, 46, 126: requested/default database branch

States 38, 46 and 126 route you toward the requested/default-database branch in current Microsoft guidance, but do not reduce the diagnosis to spelling alone. Read the accompanying Reason: the effective database can be missing, unavailable, not openable in the current deployment/state, or inaccessible through the intended login context. Availability-group/listener and failover scenarios also make it important to confirm which replica/node received the login.

Important boundary with Error 4064: the client may show Cannot open user default database. Login failed and Microsoft SQL Server, Error: 4064, while the SQL Server error log records the underlying login/database-open failure. If 4064 is the visible client error, treat 4064 as the primary troubleshooting intent; use the 18456 Reason/State here only as supporting server-side evidence.

Check the effective database name, the login’s default database, database availability, and whether the login has intended access. If another permitted database is available, specifying it temporarily can help prove that the login itself works while the default/requested database is the failing gate. Do not confuse that diagnostic test with repairing the intended database.

Verify: Connect to an available database the login is allowed to use, or correct the intended database/access. Confirm both that the database-related 18456 state is gone and that a client-facing 4064 no longer occurs when the intended database is used.

Fix #4 — states 6 or 58: align authentication mode

State 6 can indicate a Windows login name was used with SQL Server Authentication. State 58 commonly appears when SQL authentication is attempted against a Windows Authentication-only instance; Microsoft also documents SID mismatch as another possible cause.

If Windows Authentication is intended, use integrated/trusted authentication; Microsoft recommends Windows Authentication when possible. If SQL logins are genuinely required, confirm that Mixed Mode is an intentional server policy and create/use a scoped SQL login appropriate to the application.

Mixed Mode is a server-level change, not a quick checkbox fix. Changing authentication mode requires restarting the SQL Server service. Switching from Windows-only to Mixed Mode does not automatically enable sa. Microsoft describes sa as a well-known target and advises not enabling it unless the application specifically requires it. Do not enable sa merely to test Error 18456, and do not use a sysadmin login as an application credential.

Verify: The client authentication method matches the approved server configuration, the application uses the intended least-privileged identity, and the original State 6/58 is gone.

Fix #5 — domain user or states 11/12: verify Windows server access

Microsoft maps States 11 and 12 to a valid login whose server access fails. Check the Windows identity SQL Server actually receives, intended SQL Server login/group, effective group membership, explicit DENY permissions and target server. Do not infer the server-side token solely from the interactive username or service configuration you expected.

Do not make “Run as Administrator” the permanent answer. Elevation is one documented State 11 scenario, but durable access should be granted intentionally to the identity the application or user actually runs as.

Verify: test through the real application/service path and confirm the SQL Server log sees the intended Windows identity and that identity has intended server access without depending on accidental local-admin elevation.

Fix #6 — ANONYMOUS LOGON or (null): Kerberos/SPN/delegation branch

NT AUTHORITY\ANONYMOUS LOGON commonly points to a Windows authentication handoff problem. In multi-machine double-hop scenarios, Microsoft directs troubleshooting toward Kerberos, SPNs, and delegation. A (null) identity can also point to token/SPN problems.

Confirm the client → middle tier → SQL Server path, service identity, DNS/server name, and SPN ownership before changing delegation.

Security boundary: do not enable broad delegation or copy registry changes from a forum just to suppress ANONYMOUS LOGON. First prove whether the case is loopback, double hop, or a misplaced/duplicate SPN.

Verify: The SQL Server log shows the intended Windows identity rather than ANONYMOUS LOGON/(null), and the real application path succeeds.

Other states — keep the exact state

Microsoft also documents State 62 for a contained-database Windows-authentication SID mismatch, States 102–111 and 132–133 for Microsoft Entra ID failures, and 122–124 for an empty username or password. Other states can indicate unexpected internal processing errors.

Verify: Match the exact state and Reason against current Microsoft documentation for the deployment before applying a fix from a different branch.

What not to do

Do not reset a password until the Reason/State points to credentials.Do not enable Mixed Mode just because the client says Error 18456; confirm that SQL authentication is actually required and account for the service restart.Do not enable or use sa as a shortcut when a scoped identity is intended.Do not grant sysadmin merely to prove a login can connect; use an existing authorized administrator to diagnose, then test the real least-privileged identity.Do not treat ANONYMOUS LOGON as a SQL-password problem.Do not publish passwords, tokens, or secret-bearing connection strings.Do not troubleshoot an old log entry; correlate the exact attempt.Do not treat a State number by itself as a universal diagnosis; use the accompanying Reason and current documentation for the actual SQL Server deployment/version.Do not read the log from the wrong replica/instance when a listener, alias, cluster or failover path can route the client elsewhere.Do not assume the Windows identity configured on the client/middle tier is the identity SQL Server actually received; prove it from the server-side attempt.Do not keep diagnosing the original 18456 branch when the Reason/State changes after a fix; the new state can mean the connection passed the previous gate.

Still seeing Error 18456?

If the state changes after a fix, treat the new state as new evidence. Reaching a database-related state after clearing an authentication-mode state can mean you passed the first gate.

Before escalating, capture:complete client error without secretsclient endpoint plus the actual server/instance/node or replica that received the attempt, and requested databaselogin identity and authentication typematching server-log textual Reason and State, interpreted against current documentation for that deployment/versiontimestamp and client/applicationwhether SSMS and the real application differSQL Server version/deploymentfor Windows auth: service identity and whether a double hop exists

Official references

Still stuck? Ask the community

Share the redacted Reason/State, SQL Server version, authentication type, and whether the failure comes from SSMS, an application, or a multi-tier service.

Keep it safe: never post passwords, secret-bearing connection strings, access tokens, private keys, or confidential credentials.
Powered by GitHub DiscussionsSign in with GitHub to comment. Reading comments does not require sign-in.

Loading community discussion…