SQL Server Error 18456 Solved: The 2-Minute Fix for ‘Login Failed’
⚡ Quick Answer
SQL Server Error 18456 occurs when a user attempts to connect to SQL Server but the authentication process fails. To fix the most common cause immediately: open SQL Server Management Studio (SSMS) using Windows Authentication, right-click your server instance → Properties → Security, and change the Server Authentication mode to “SQL Server and Windows Authentication mode.” Restart the SQL Server service to apply the fix.
If you are a database administrator or developer, seeing the dreaded “Login failed for user (Microsoft SQL Server, Error: 18456)” message can instantly halt your workflow. Fortunately, this is one of the most common—and easily fixable—SQL Server issues.
In this guide, we will break down exactly why this error happens, what the different “State Codes” mean, and how to resolve it quickly so you can get back to building amazing applications.
Why Does Error 18456 Occur?
By default, Microsoft SQL Server installs with Windows Authentication only. When a user tries to log in using a specific SQL Server username (like sa) and password, the server outright rejects it because standard SQL Authentication is disabled.
However, there are other reasons you might see this error. To pinpoint the exact cause, you need to look at the State Code included in the server’s error logs.
Common State Codes for Error 18456
Microsoft smartly hides the exact reason for the login failure from the end-user client to prevent security probing and brute-force attacks. However, the server logs securely record a State Code.
| State Code | Meaning / Root Cause | How to Fix |
|---|---|---|
| State 1 | General error (usually masking another state). | Check server logs for the real state code. |
| State 2 or 5 | Invalid User ID. | Verify the username is spelled correctly. |
| State 6 | Attempted to use a Windows login name with SQL Authentication. | Switch to Windows Authentication on the login prompt. |
| State 7 | Login disabled or password mismatch. | Enable the account or reset the password via SSMS. |
| State 58 | Server configured for Windows Authentication only. | Enable Mixed Mode Authentication in Server Properties. |
Step-by-Step Fix: Enabling Mixed Mode Authentication
If you are encountering State 58, here is the exact process to resolve the issue:
- Step 1: Open SQL Server Management Studio (SSMS).
- Step 2: Connect to the database engine using Windows Authentication.
- Step 3: In the Object Explorer, right-click the server name and select Properties.
- Step 4: Navigate to the Security page in the left pane.
- Step 5: Under Server authentication, select the radio button for SQL Server and Windows Authentication mode.
- Step 6: Click OK. A prompt will remind you to restart the SQL Server service.
- Step 7: Right-click the server name again in Object Explorer and click Restart.
For more detailed technical documentation on state codes, you can always refer to the official Microsoft SQL Server documentation.
📌 TL;DR – Summary of Error 18456
- Error 18456 means a login attempt failed due to authentication issues or incorrect credentials.
- The most common reason (State 58) is that Mixed Mode Authentication is not enabled upon installation.
- Always check the SQL Server Error Logs to find the specific State Code (e.g., State 2 = Invalid Username, State 7 = Disabled Login).
- Fix the most common issue by changing server properties to “SQL Server and Windows Authentication mode” and restarting the SQL Server service.