Msg 18456 Login Failed for User in SQL Server: Causes and Fix

SQL Server 3 min readUpdated Dec 1, 2026
1 view0 comments

You connect to SQL Server and get this:

Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Login failed for user 'taylor_app'..

Msg 18456 means the server refused the login. The message is vague on purpose; the real reason, with a State number, is in the server error log. Read the State, then fix that one thing.

Part of the SQL Server Errors Explained series. The results were captured on a SQL Server 2025 Developer test instance with a throw-away login and database, dropped afterwards. States 38, 40 and 58 were not triggered; they are the documented meanings.


Contents

1. The quick fix

Connect with a login that works (for example your Windows admin login) and list the failures with their reason. Change the name and the date:

SET NOCOUNT ON;
DECLARE @log TABLE (d datetime, src nvarchar(50), msg nvarchar(4000));
DECLARE @out nvarchar(4000) = N'';
INSERT @log EXEC sp_readerrorlog 0, 1, N'Error: 184';
INSERT @log EXEC sp_readerrorlog 0, 1, N'Login failed', N'taylor_app';

SELECT @out += e.msg + ' ' + LEFT(r.msg, CHARINDEX('[', r.msg) - 1)
               + CHAR(13) + CHAR(10)
FROM @log e JOIN @log r ON r.d = e.d AND r.msg LIKE 'Login failed%'
WHERE e.msg LIKE 'Error:%'
  AND e.d > '2026-12-01 23:24' ORDER BY e.d;
PRINT @out;
Error: 18456, Severity: 14, State: 8. Login failed for user 'taylor_app'. Reason: Password did not match that for the login provided.
Error: 18456, Severity: 14, State: 5. Login failed for user 'taylor_apps'. Reason: Could not find a login matching the name provided.
Error: 18456, Severity: 14, State: 7. Login failed for user 'taylor_app'. Reason: An error occurred while evaluating the password.
Error: 18470, Severity: 14, State: 1. Login failed for user 'taylor_app'. Reason: The account is disabled.

The script pairs the two log lines by their time, so on a very busy server check that the pair belongs together. With the right name and password, the same connection works:

ConnectedTo
-----------
Err18456Demo

2. What the State means

State Cause Check
8 Wrong password Type it again, check the app’s config
5 The login does not exist SELECT name FROM sys.sql_logins
7 Login disabled and wrong password is_disabled in sys.sql_logins
38, 40 The database, or the default database, cannot be opened SELECT name, state_desc FROM sys.databases
58 SQL login on a Windows-only server SERVERPROPERTY, section 4

3. Disabled login: 18456 or 18470

In our test, a disabled login with a wrong password gave 18456 State 7. With the right password it gave a different error, 18470, which says openly that the account is disabled. Find out why it was disabled, then:

USE master;

ALTER LOGIN taylor_app ENABLE;

SELECT name, is_disabled
FROM sys.sql_logins
WHERE name = N'taylor_app';
name        is_disabled
taylor_app  0

4. Windows logins only

-- 1 = Windows only, 0 = mixed mode
SELECT SERVERPROPERTY('IsIntegratedSecurityOnly')
       AS WindowsOnly;
WindowsOnly
0

If it shows 1, SQL logins are refused. Server properties, Security page, then a service restart changes it. Ask the administrator first.

5. Prevent it

  • One login per application, its name in one config file.
  • Change a password on the server and in the application together.
  • Check that the login’s default database exists.

6. FAQ

Why does the client not show the reason? So that a stranger cannot learn which login names exist.

To create a login with only the permissions it needs, read SQL Server Logins, Users and Permissions.

Did you find this helpful?Tap the heart to let us know. It takes one second and no account.

More tutorials like this

Leave a Comment

Your email address will not be published. Required fields are marked *

Bigland Network IT

Practical tutorials for people who run, build and fix things: operating systems, databases, development, networking and security.

Topics

More

Site

© 2026 Bigland Network. All rights reserved.Always test commands on a non-production system first.
Scroll to Top