criticalSQL ServerError 18456

SQL Server Error 18456: Login Failed for User

Error Message
Login failed for user 'sa'. (Microsoft SQL Server, Error: 18456)
State 8: Incorrect password

What is SQL Server Error 18456?

SQL Server Error 18456 is an authentication failure. SQL Server's error log contains the critical 'State' code which pinpoints the exact reason: wrong password, account disabled, SQL auth not enabled, or database access issue.

Common Causes

  • 1

    State 8: Wrong password

  • 2

    State 5: SQL Server login does not exist

  • 3

    State 16: Login does not have access to the default database

  • 4

    State 38: SQL Server authentication mode is Windows-only

  • 5

    State 11: Login is valid server login but invalid database user

  • 6

    State 1: Account locked out or disabled

Step-by-Step Solutions

1

Check SQL Server Error Log for the State code: SSMS > Management > SQL Server Logs

2

Enable SQL Server Authentication: SSMS > Server Properties > Security > SQL Server and Windows Authentication Mode

3

Reset password in SSMS: Security > Logins > right-click login > Properties > change password

4

Fix default database: ALTER LOGIN username WITH DEFAULT_DATABASE = [master]

5

Enable disabled account: ALTER LOGIN username ENABLE

6

For 'sa' disabled: ALTER LOGIN sa WITH PASSWORD = 'newpass', NAME = sa; ALTER LOGIN sa ENABLE;

Prevention Tips

  • Use Windows Authentication instead of SQL Authentication where possible — more secure

  • Enable SQL Server auditing to log authentication attempts

  • Use strong password policies: ALTER LOGIN username WITH CHECK_POLICY = ON

  • Store connection strings in encrypted configuration or secrets management systems

Frequently Asked Questions

How do I find the state code for SQL Server Error 18456?
The state code appears in SQL Server's error log, not the client error message. Access it via: SSMS > Object Explorer > Management > SQL Server Logs > current log. Search for 18456. The state code (e.g., 'Login failed for user. Reason: Password did not match. State: 8') tells you exactly why authentication failed.
How do I enable SQL Server authentication mode?
In SSMS: right-click Server > Properties > Security tab > select 'SQL Server and Windows Authentication mode' > click OK. Then restart SQL Server service. This enables sa and SQL logins in addition to Windows authentication.

Related Errors

Still Stuck?

Ask our AI SQL Assistant or the community — get answers in seconds.