This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Download Microsoft Edge More info about Internet Explorer and Microsoft EdgeYou get this error message when a connection attempt is rejected because of an authentication failure. User logins can fail for many reasons, such as invalid credentials, password expiration, and enabling the wrong authentication mode. In many cases, error codes include descriptions.
The following examples are some of the common login failures. Select the exact error that you're experiencing to troubleshoot the issue:
Login failed for user '<username>' or login failed for user '<domain>\<username>'
Login failed for user '(null)'
If the domain name isn't specified, the problem is a failing SQL Server login attempt. If the domain name is specified, the problem is a failing Windows user account login. For potential causes and suggested resolutions, see:
Potential cause Suggested resolution You're trying to use SQL Server Authentication , but the SQL server instance is configured for Windows Authentication mode. Verify that SQL Server is configured to use SQL Server and Windows Authentication mode . You can review and change the authentication mode for your SQL Server instance on the Security page under Properties for the corresponding instance in SQL Server Management Studio (SSMS). For more information, see Change server authentication mode . Alternatively, you can change your application to use Windows Authentication mode to connect to SQL Server.
Login failed for user '<UserName>'. Reason: An attempt to login using SQL authentication failed. Server is configured for Windows authentication only.
Login doesn't exist on the SQL Server instance you're trying to connect to.
Verify that the SQL Server login exists and that you've spelled it properly. If the login doesn't exist, create it. If it's present but misspelled, correct that in the application connection string. The SQL Server Errorlog will have one of the following messages:
Login failed for user 'username'. Reason: Could not find a login matching the name provided.
Login failed for user 'Domain\username'. Reason: Could not find a login matching the name provided.
This can be a common issue if you deploy an application that uses a DEV or QA server into production and you fail to update the connection string. To resolve this issue, validate that you are connecting to the appropriate server. If not, correct the connection string. If it is, grant the login access to your SQL Server. Or if it's a windows login grant access directly or add it to a local or domain group that is allowed to connect to the database server. For more information, see
Create a Login
.
You're using
SQL Server Authentication
, but the password you specified for SQL Server login is incorrect.
Check the SQL error log for messages like "
Reason: Password did not match that for the login provided
" to confirm the cause. To fix the issue, use the correct password in your application or use a different account if you can't remember the password. Alternatively, work with your SQL Server administrator to reset the password for the account.
Cannot open user default database. Login failed.
Login failed for user <user name>. (Microsoft SQL Server, Error: 4064)
Login failed for user '<user name>'. Reason: Failed to open the database '<dbname>' specified in the login properties [CLIENT: <ip address>]
Login failed for user <UserName>. Reason: Failed to open the explicitly specified database 'dbname'. [CLIENT: <ip address>]
CREATE USER [<UserName>] FOR LOGIN [UserName]
)
Also, check the extensive list of error codes at Troubleshooting Error 18456 .
For more troubleshooting help, see Troubleshooting SQL Client / Server Connectivity Issues .
There are at least four scenarios for this issue. In the following table, examine each applicable potential cause, and use the appropriate resolution: See the note below the table for an explanation of the term double hop .
Potential causes Suggested resolutions You're trying to pass NT LAN Manager (NTLM) credentials from one service to another service on the same computer (for example: from IIS to SQL server), but a failure occurs in the process. Add the DisableLoopbackCheck or BackConnectionHostNames registry entries. There are double-hop (constraint delegation) scenarios across multiple computers. The error could occur if the Kerberos connection fails because of Service Principal Names (SPN) issues. Run SQLCheck on each SQL Server and the web server. Use the troubleshooting guides: 0600 Credential Delegation Issue and 0650 SQL Server Linked Server Delegation Issues . If no double-hop (constraint delegation) is involved, then likely duplicate SPNs exist, and the client is running as a LocalSystem or another machine account that gets NTLM credentials instead of Kerberos credentials. Use SQLCheck or Setspn.exe to diagnose and fix any SPN-related issues. Also review Overview of the Kerberos Configuration Manager for SQL Server . Windows Local Security policy may have been configured to prevent the use of the machine account for remote authentication requests. Navigate to Local Security Policy > Local Policies > Security Options > Network security: Allow Local System to use computer identity for NTLM , select the Enabled option if the setting is disabled, and then select OK .A double-hop typically involves delegation of user credentials across multiple remote computers. For example, assume you have a SQL Server instance named SQL1 where you created a linked server for a remote SQL Server named SQL2 . In linked server security configuration, you selected the option Be made using the login's current security context . When using this configuration, if you execute a linked server query on SQL1 from a remote client computer named Client1 , the windows credentials will first have to hop from Client1 to SQL1 and then from SQL1 to SQL2 (hence, it's called a double-hop). For more information, see Understanding Kerberos Double Hop and Kerberos Constrained Delegation Overview
This error occurs when a user tries unsuccessfully to log in. This error might occur if your computer isn't connected to the network. For example, you may receive an error message that resembles the following one:
Source: NETLOGON
Date: 8/12/2012 8:22:16 PM
Event ID: 5719
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: <computer name>
Description: This computer was not able to set up a secure session with a domain controller in domain due to the following: The remote procedure call was cancelled.
This may lead to authentication problems. Make sure that this computer is connected to the network. If the problem persists, please contact your domain administrator.
An empty string means that SQL Server tried to hand off the credentials to the Local Security Authority Subsystem Service (LSASS) but couldn't because of some problem. Either LSASS wasn't available, or the domain controller couldn't be contacted.
Check the event logs on the client and the server for any network-related or Active Directory-related messages that were logged around the time of the failure. If you find any, work with your domain administrator to fix the issues.
Login failed for user '(null)'
An indication of "null" could mean that LSASS can't decrypt the security token by using the SQL Server service account credentials. The main reason for this condition is that the SPN is associated with the wrong account.
To fix the issue, follow these steps:
Use the SQLCheck or Setspn.exe to diagnose and fix SPN-related issues.
Use SQLCheck to check whether the SQL Service account is trusted for delegation. If the output indicates that the account isn't trusted for delegation, work with your Active Directory administrator to enable delegation for the account.
Diagnose and fix Domain Name System (DNS) name resolution issues. For example:
Ping IP address by using PowerShell scripts:
ping -a <your_target_machine>
(use -4
for IPv4 and -6
IPv6 specifically)
ping -a <your_remote_IPAddress>
Use NSLookup to enter your local and remote computer name and IP address multiple times.
Look for any discrepancies and mismatches in the returned results. The accuracy of the DNS configuration on the network is important for a successful SQL Server connection. An incorrect DNS entry could cause numerous connectivity issues later.
Make sure that firewalls or other network devices don't block a client from connecting to the domain controller. SPNs are stored in Active Directory. If the clients can't communicate with the directory, the connection can't succeed.
Additional error information
To increase security, the error message that is returned to the client deliberately hides the nature of the authentication error. However, in the SQL Server error log, a corresponding error contains an error state that maps to an authentication failure condition. Compare the error state to the following list to determine the reason for the login failure.
State
Description
Error information isn't available. This state usually means you don't have permission to receive the error details. Contact your SQL Server administrator for more information.
User ID isn't valid.
User ID isn't valid.
An attempt was made to use a Windows login name with SQL Server Authentication.
Login is disabled, and the password is incorrect.
The password is incorrect.
Password isn't valid.
Login is valid, but server access failed. One possible cause of this error is when the Windows user has access to SQL Server as a member of the local administrators' group, but Windows isn't providing administrator credentials. To connect, start the connecting program using the Run as administrator option, and then add the Windows user to SQL Server as a specific login.
Login is valid login, but server access failed.
Password must be changed.
38, 46
Couldn't find database requested by user.
When SQL Server is set to use Windows Authentication only, and a client attempts to log in using SQL authentication. Another cause is when SIDs don't match.
102 - 111
Azure AD failure.
122 - 124
Failure due to empty user name or password.
Database requested by user doesn't exist.
132 - 133
Azure AD failure.
Other error states exist and signify an unexpected internal processing error.
More rare possible cause
The error reason An attempt to login using SQL authentication failed. Server is configured for Windows authentication only. can be returned in the following situations.
When the server is configured for mixed mode authentication, and an ODBC connection uses the TCP protocol, and the connection doesn't explicitly specify that the connection should use a trusted connection.
When SQL server is configured for mixed mode authentication, and an ODBC connection uses named pipes, and the credentials the client used to open the named pipe are used to automatically impersonate the user, and the connection string doesn't explicitly specify the use of a trusted authentication.
To resolve this issue, include TRUSTED_CONNECTION = TRUE
in the connection string.
Examples
In this example, the authentication error state is 8. This indicates that the password is incorrect.
Source
Message
When SQL Server is installed using Windows Authentication mode and is later changed to SQL Server and Windows Authentication mode, the sa login is initially disabled. This causes the state 7 error: "Login failed for user 'sa'." To enable the sa login, see Change Server Authentication Mode.
See also
0420 Reasons for Consistent Auth Issues