SQL Server Error 18456: Login Failed for User (Complete Guide)

Common SQL Errors

Authentication

Error 18456 means SQL Server rejected a login request because authentication failed, often from wrong credentials, disabled logins, or insufficient permissions.

Microsoft 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 Microsoft SQL Server error 18456?

SQL Server error 18456, “Login failed for user,” is an authentication failure. Verify the login name and password, enable the account, pick the correct authentication mode, and grant the right database permissions to resolve the issue.

Typical Error Message

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

Explanation

What is Microsoft SQL Server error 18456?Error 18456 appears when SQL Server denies a connection attempt because authentication failed.The message always reads “Login failed for user,” followed by a state code that pinpoints the root cause.

What Causes This Error?Wrong password or misspelled login immediately trigger state 8 in error 18456.Mixed-mode disabled on the server rejects SQL logins with state 58.Disabled, locked-out, or expired accounts surface as state 7, 11, or 12.Default database offline or dropped returns state 13.Missing CONNECT permission on the target database yields state 16 or 18.

How to Fix SQL Server Error 18456Confirm valid credentials by logging in through SSMS with the same login.If credential checks fail, reset the password or re-enter it in your app.For SQL logins, enable mixed-mode in Server Properties → Security.Unlock or enable the login with ALTER LOGIN … ENABLE/UNLOCK.Grant CONNECT rights on the required database and set a valid default database.

Common Scenarios and SolutionsState 8: Wrong password – reset or re-enter credentials.State 38: Database unavailable – bring the database online or point login to master.State 58: Login using SQL auth while server allows Windows only – enable mixed-mode.State 11/12: Login disabled – run ALTER LOGIN … ENABLE.

Best Practices to Avoid This ErrorStore connection strings in secure vaults to prevent typos during deployment.Enable password expiration alerts and rotate secrets proactively.Monitor the SQL Server error log for repeated state codes and react early.Use Galaxy’s AI copilot to autocomplete valid database names and flag offline targets before execution.

Related Errors and SolutionsError 4060 “Cannot open database requested by the login” occurs when the database is offline; bring it online or map the user.Error 233 “No process is on the other end of the pipe” often follows 18456 when TCP/IP is disabled; enable the protocol.Cross-platform equivalents such as MySQL 1045 or Oracle ORA-01017 indicate similar authentication failures; the repair steps are parallel—verify credentials and grant permissions.

Common Causes

Incorrect password or login name entered in the connection string.

SQL Server configured for Windows Authentication only while the client uses SQL Authentication.

Login locked out after too many failed attempts or manually disabled by an administrator.

Account’s default database offline, restoring, or dropped.

Missing CONNECT permission on the targeted database or server-level DENY.

Password expired or enforced change required on next login.

Related Errors

Error 4060 – Cannot open database requested by the login; Error 233 – No process is on the other end of the pipe; Error 1326 – Client unable to establish connection; ORA-01017 – Invalid username/password in Oracle

FAQs

How do I find the state code for error 18456?

Open the SQL Server error log or run xp_readerrorlog; the state code appears alongside the message and pinpoints the root cause.

Does enabling mixed-mode weaken security?

Mixed-mode itself is not insecure, but you must enforce strong passwords and restrict SQL logins to mitigate brute-force risks.

Why does 18456 happen only from one application?

The app likely stores outdated credentials or points to a wrong database—update the connection string and test again.

Can Galaxy stop 18456 before it happens?

Galaxy’s AI copilot validates credentials during query generation and warns about offline databases, helping you catch authentication issues early.

Check out some other errors

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