Understanding and Resolving SQL Server Error 18456
Grace Collins
Solutions Engineer · Leapcell

Key Takeaways
- SQL Server Error 18456 occurs due to failed authentication during login attempts.
- Different state codes with Error 18456 indicate specific reasons for login failure.
- Resolving the error involves verifying credentials, checking authentication mode, and reviewing SQL logs.
SQL Server Error 18456 is a common authentication error encountered when attempting to connect to a Microsoft SQL Server instance. This error indicates that the login attempt has failed, but the underlying cause can vary depending on the specific state code provided alongside the error. Understanding these state codes is crucial for diagnosing and resolving the issue effectively.
What Is SQL Server Error 18456?
When a login attempt to SQL Server fails, the server returns Error 18456 along with a state code that provides more detail about the reason for the failure. The general error message is:
Login failed for user '<username>'. (Microsoft SQL Server, Error: 18456)
The accompanying state code helps pinpoint the exact cause of the failure.
Common State Codes and Their Meanings
Here are some frequently encountered state codes associated with Error 18456:
-
State 1: Error information is not available. This state usually means you do not have permission to receive the error details.
-
State 2 and 5: Invalid user ID. The username entered does not exist.
-
State 6: Attempt to use a Windows login name with SQL Authentication.
-
State 7: Login disabled. The login is disabled, and the password is incorrect.
-
State 8: Password is incorrect. The password entered is incorrect.
-
State 11 and 12: Valid login but server access failure. The login is valid, but server access failed.
-
State 13: SQL Server service paused. The SQL Server service is paused.
-
State 16: Authorization succeeded, but the user does not have access to the specified database.
-
State 18: Change password required. The password must be changed before logging in.
-
State 38: Could not find the specified database. The database requested by the login does not exist.
-
State 58: SQL Server is configured to allow Windows Authentication only, and a client attempted to connect using SQL Authentication.
Understanding these state codes can significantly aid in troubleshooting and resolving login issues.
Steps to Resolve SQL Server Error 18456
-
Verify Credentials: Ensure that the username and password are correct. Pay attention to case sensitivity and any potential typographical errors.
-
Check Authentication Mode: Confirm that SQL Server is configured to allow the type of authentication you are using (Windows Authentication or SQL Server Authentication). You can check and change this setting in SQL Server Management Studio (SSMS) under server properties.
-
Enable the Login: If the login is disabled, you can enable it using the following T-SQL command:
ALTER LOGIN [username] ENABLE;
-
Reset the Password: If the password is incorrect or has expired, reset it using:
ALTER LOGIN [username] WITH PASSWORD = 'new_password';
-
Assign Appropriate Permissions: Ensure that the login has the necessary permissions to access the desired database. You can assign roles or specific permissions as needed.
-
Check Default Database: If the default database assigned to the login is unavailable, specify a different database in the connection string or change the default database for the login.
-
Review SQL Server Logs: Examine the SQL Server error logs for more detailed information about the login failure. The logs can provide insights into the exact cause of the error.
Additional Resources
For more in-depth information and troubleshooting steps, consider the following resources:
FAQs
It is an authentication error that occurs when login attempts to SQL Server fail.
State codes provide details about why the login failed, guiding specific troubleshooting steps.
Verify credentials, enable correct authentication mode, and ensure user permissions.
We are Leapcell, your top choice for hosting backend projects.
Leapcell is the Next-Gen Serverless Platform for Web Hosting, Async Tasks, and Redis:
Multi-Language Support
- Develop with Node.js, Python, Go, or Rust.
Deploy unlimited projects for free
- pay only for usage — no requests, no charges.
Unbeatable Cost Efficiency
- Pay-as-you-go with no idle charges.
- Example: $25 supports 6.94M requests at a 60ms average response time.
Streamlined Developer Experience
- Intuitive UI for effortless setup.
- Fully automated CI/CD pipelines and GitOps integration.
- Real-time metrics and logging for actionable insights.
Effortless Scalability and High Performance
- Auto-scaling to handle high concurrency with ease.
- Zero operational overhead — just focus on building.
Explore more in the Documentation!
Follow us on X: @LeapcellHQ