"The target principal name is incorrect. Cannot generate SSPI context. (.Net SqlClient Data Provider)"

Hello SQL Expert,

When I try to connect SQL Server using SSMS then I got the following error. But in the error log I found that Logon Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. Reason: Failed to open the explicitly specified database. [CLIENT: ]

NB. The SQL Server Service running under the 'NT AUTHORITY\NETWORK SERVICE'. But I can connect locally using SQLCMD

Cannot connect to …..

"The target principal name is incorrect. Cannot generate SSPI context. (.Net SqlClient Data Provider)"

Please advise!

Whatever the server is in your connection string needs to be registered as an SPN to generate an SSPI context. https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/register-a-service-principal-name-for-kerberos-connections?view=sql-server-2017

Thanks for replying. But without SPN registered I see couple SQL instances not experiencing this issue and why is that.