The target principal name is incorrect. Cannot generate SSPI context The target principal name is incorrect. Cannot generate SSPI context sql-server sql-server

The target principal name is incorrect. Cannot generate SSPI context


I had this problem with an ASP.NET MVC app I was working on.

I realized I had recently changed my password, and I was able to fix it by logging out and logging back in again.


Try setting Integrated Security=true to remove this param from the connection string.


IMPORTANT: As user @Auspex commented,

Removing Integrated Security will prevent this error, because the error occurs when trying to login with your Windows credentials. Unfortunately, most of the time, you want to be able to login with your Windows credentials


I was getting the same error when trying through windows authentication. Sounds ludicrous but just in case it helps someone else: it was because my domain account got locked somehow while I was still logged in (!). Unlocking the account fixed it.