Applications cannot login to moved db with Error: 18456 Severity: 14 State: 38 after AG failover

Andrea Floriddia 20 Reputation points
2026-06-29T08:21:31.8566667+00:00

IaaS SQL Server on 2-node cluster with Always On
Manual AG failover was successfull but applications can no longer connect. SQLServer logs report "Error: 18456 Severity: 14 State: 38" and
"Login failed for user 'app_rh_sso'. Reason: Failed to open the explicitly specified database 'RH_SSO'"

Failing back the AG the application reconnect successfully

What could be the causes? I discovered that the login on the other node has a different SID compared to the database user. Could this be the reason?

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

Answer accepted by question author

Erland Sommarskog 135.3K Reputation points MVP Volunteer Moderator
2026-06-29T08:38:11.4033333+00:00

I discovered that the login on the other node has a different SID compared to the database user. Could this be the reason?

Yes, that is the reason. Mapping between login on server level and user on database level is by SID, not by name. This is mainly an issue with SQL logins, since Windows logins get their SID from the AD.

The remedy is to drop the login on the secondary and create it, using the SID option:

CREATE LOGIN NisseNils WITH PASSWORD = 'Top$ecret!', SID = 0x....

You get the SID value from what's on the primary.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.