SQL Server error 18456 is a generic “Login failed” message that appears when the server rejects a user’s authentication request.
SQL Server error 18456 means the server rejected the login. The state code tells you why—wrong password, disabled login, or auth-mode mismatch. Check the state in the SQL Server error log, correct the credentials or enable the login, and retry the connection.
Login failed for user '<login>'. (Microsoft SQL Server, Error: 18456)
Error 18456 is SQL Server’s generic “Login failed” message that surfaces when authentication fails for a login. The error hides security details from the client, but the SQL Server error log records a state code that pinpoints the exact reason.Fixing the issue quickly matters because repeated failures can lock accounts, break applications, and flood logs. Understanding the state code lets you apply the right remedy—password reset, login enablement, or mode change—without guesswork.
Incorrect credentials trigger state 8 or 18; the supplied password does not match the stored hash for the login.Disabled or locked-out logins return state 7 because the account is disabled or exceeded password retry limits.Authentication-mode mismatch appears as state 58: the server runs in Windows-only mode while the client uses a SQL login.State 16 means the login is valid, but it lacks permission to connect to the requested database or the database is offline.
Read the state code in ERRORLOG with xp_readerrorlog
; it exposes the root cause hidden from the client.For wrong passwords (state 8/18), reset the password with ALTER LOGIN … WITH PASSWORD
and update the connection string.If the login is disabled (state 7), enable it using ALTER LOGIN … ENABLE
and optionally turn off check policy for service accounts.Switch to Mixed Mode authentication in Server Properties or registry when SQL logins must connect (state 58).Grant database access for state 16 with CREATE USER
and add the user to needed roles.
After password rotation, hard-coded credentials in apps fail with 18456 state 8; update secrets or use a vault.SQL Agent jobs may stop when their proxy login is disabled (state 7); re-enable the login or assign a new credential.Containers often default to Windows-only auth, producing state 58; configure Mixed Mode during the Docker build.
Rotate passwords securely and enforce policies to reduce forgotten or compromised credentials.Monitor ERRORLOG for surges of 18456 entries and alert on abnormal spikes to detect brute-force attacks early.Use contained database users where possible to remove reliance on server-level authentication.Galaxy’s modern SQL editor highlights login failures instantly, offers AI-generated fixes, and lets teams share validated connection snippets, preventing repeated 18456 errors.
Error 18452: login failed because the user is not associated with a trusted connection—enable Mixed Mode or use Windows auth.Error 4060: login succeeded but the target database is unavailable—bring the database online or grant the user access.
- Wrong password or username (state 8/18)- Disabled or locked login (state 7)- Server in Windows-only authentication mode (state 58)- Login lacks access to the requested database (state 16)- SQL Server service restarted with different security context
- Error 18452: Login failed—user not associated with a trusted SQL Server connection.- Error 4060: Cannot open database requested by the login.- Error 233: No process is on the other end of the pipe during login.- Error 17187: SQL Server is not ready to accept new client connections.
Run xp_readerrorlog
or view the SQL Server Error Log in Management Studio. The state code appears after the error number and explains the exact cause.
No. The password is only one cause (states 8 and 18). Other states indicate disabled logins, auth-mode mismatch, or missing database access.
Mixed Mode itself isn’t insecure, but you must enforce strong passwords, rotate secrets, and limit SQL logins to necessary roles.
Yes. Galaxy surfaces login errors immediately, suggests AI-driven fixes, and lets teams share corrected connection settings to prevent future failures.