FIX: cannot generate SSPI context error [SQL Server]

by Tashreef Shareef
Tashreef Shareef
Tashreef Shareef
Windows & Software Expert
Tashreef Shareef is a software developer turned tech writer. He discovered his interest in technology after reading a tech magazine accidentally. Now he writes about everything tech from... read more
Affiliate Disclosure
  • The error cannot generate SSPI context can prevent the admin and users from accessing their SQL server.
  • In this article, we explore the three ways to fix this error to get you back online.
  • If the issue persists, check out our dedicated SQL Server page for more fixes.
  • You can also explore our Troubleshooting Hub for more helpful solutions.
SQL server login error
To fix various PC problems, we recommend DriverFix:
This software will keep your drivers up and running, thus keeping you safe from common computer errors and hardware failure. Check all your drivers now in 3 easy steps:

  1. Download DriverFix (verified download file).
  2. Click Start Scan to find all problematic drivers.
  3. Click Update Drivers to get new versions and avoid system malfunctionings.
  • DriverFix has been downloaded by 0 readers this month.

The target principal name is incorrect – cannot generate SSPI context error occurs when trying to make a connection on SQL Server from a remote server with a Windows account. 

This is a generic error. It can be triggered due to many reason including an outdated password, clock drift, failure to register an SPN, or Active Directory access permission.

In this article, we take a look at a few troubleshooting steps to help you resolve the cannot generate SSPI context error on the Windows server.

How can I fix the target principal name is incorrect – cannot generate SSPI context error?

1. Change SQL Service User

cannot generate SSPI context

Try changing the SQL SERVICE user with the one that is Domain Admin. When you shut down the service, you need an account with privileges to create a new SPN (Service Principal Name).

When a service starts without it, it will trigger the error. Changing the privileges of your system account can fix the error.

However, it is always recommended for service accounts to give them the least privileges due to security reasons.

Remove the SPN entries from AD Users and Computers

  1. Open the Active Directory User and Computers in Advanced View.
  2. Look for the SSPN entries for MSSQL Svc.
  3. Remove all the entries associated with MSSQL Svc.
  4. Close AD User and Computers and check for any improvements.
  5. Change Active Directory permission.

2. Check your password

cannot generate SSPI context

The error cannot generate SSPI context can occur due to password issues. If you had recently changed your password, but haven’t logged out of your account, it can trigger the error.

Try logging out and then signing in with the new password to fix the error.

In other instances, the issue could be due to password expiration. Change the expired password and login with the new credentials to see if that resolves the error.

3. Change Active Directory permission 

cannot generate SSPI context

  1. Run Adsiedit.msc and from the Run dialog box.
  2. In the Active Directory Service window, expandDomain [YourDomainName],  then expand DC = RootDomainName, and then CN = Users.
  3. Right-click on CN= [YourAccountName] and select Properties.
  4. Open the Security tab.
  5. Click on Advanced option.
  6. Select any one of the SELF rows.
  7. Click Edit and then the Open Permission Entry window.
  8. Here, make sure the Principal is set to SELF, Type is set to Allow, and Applied to is set to This Object Only.
  9. In the Properties section, select the following.
    Read servicePrincipalName
    Write servicePrincipalName
  10. Click OK to apply the changes and exit.

Try establishing a new connection and check if they cannot generate SSPI context error is resolved. Make sure you restart the SQL Services that are associated with the current account to apply the changes.

Changing the Active Directory permission is a safe option than changing the SQL server user. However, before you proceed to change the permission, make sure the problem is triggered due to permission issues.

Log in to the server where your SQL instance is running and then check the error logs to check if the error is triggered due to permission problems.

The error in the log will look something like this:

The SQL Server Network Interface library could not register the Service Principal Name (SPN) [ MSSQLSvc/ ] for the SQL Server service.
Windows return code: 0x2098, state: 15. Failure to register an SPN might cause integrated authentication to use NTLM instead of Kerberos.
This is an informational message. Further action is only required if Kerberos authentication is required by authentication policies and if the SPN has not been manually registered.

The error cannot generate SSPI context can occur due to permission as well as expired credentials issues. Changing the password and permission should help you fix the error and log back into your SQL server.

idee restoro Still having issues? Fix them with this tool:
  1. Download this PC Repair Tool rated Great on (download starts on this page).
  2. Click Start Scan to find Windows issues that could be causing PC problems.
  3. Click Repair All to fix issues with Patented Technologies (Exclusive Discount for our readers).

Restoro has been downloaded by 0 readers this month.

This article covers:Topics: