Login failed for user - Error 18456 - Severity 14, State 38

State codes and their meaning.

1      'Account is locked out'
2      'User id is not valid'
3-4    'Undocumented'
5      'User id is not valid'
6      'Undocumented'
7      'The login being used is disabled'
8      'Incorrect password'
9      'Invalid password'
10     'Related to a SQL login being bound to Windows domain password policy enforcement.
        See KB925744.'
11-12  'Login valid but server access failed'
16     'Login valid, but not permissioned to use the target database'
18     'Password expired'
27     'Initial database could not be found'
38     'Login valid but database unavailable (or login not permissioned)'

More detailed information is available in Aaron Bertrand's blog.

To find the status code, you need to inspect the SQL Server Error Log after ensuring that failed logins are recorded in the error log.


I had the same error with state code 38 caused by a typo of the name of the database in the connection string.


Here is what I found when I resolved this error: I had created some SQL connections using windows login and not user name and password. Not really sure what or how it happened but it did. I deleted them and then rebuilt my entity models. I used another connection string that I knew to be good, and all is joy. Key is Persist Security Info=True, which will not work on a network or external web site