SQL Server Login Error 18456: Causes, States, and Fixes

Common SQL Errors

Authentication

SQL Server error 18456 is a generic “Login failed” message that appears when the server rejects a user’s authentication request.

SQL Server
Sign up for the latest in common SQL errors from the Galaxy Team!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

What is SQL Server error 18456?

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.

Typical Error Message

Login failed for user '<login>'. (Microsoft SQL Server, Error: 18456)

Explanation

What is 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.

What Causes This Error?

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.

How to Fix SQL Server error 18456

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.

Common Scenarios and Solutions

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.

Best Practices to Avoid This Error

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.

Related Errors and Solutions

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.

Common Causes

- 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

Related Errors

- 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.

FAQs

How do I find the state code for error 18456?

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.

Does error 18456 always mean the password is wrong?

No. The password is only one cause (states 8 and 18). Other states indicate disabled logins, auth-mode mismatch, or missing database access.

Will enabling Mixed Mode authentication reduce security?

Mixed Mode itself isn’t insecure, but you must enforce strong passwords, rotate secrets, and limit SQL logins to necessary roles.

Can Galaxy help troubleshoot 18456?

Yes. Galaxy surfaces login errors immediately, suggests AI-driven fixes, and lets teams share corrected connection settings to prevent future failures.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
Truvideo Logo