Azure SQL connection issue: "Cannot open server" requested by the login, and login failed

Feng, QingTang 20 Reputation points
2024-01-16T10:15:15.87+00:00
I am receiving a Microsoft.Data.SqlClient.SqlException message saying "Cannot open server 'xxxxxxxxserver.database.windows.net' requested by the login. The login failed".

This error occurs when I try to connect to Azure SQL. The password and user name are correct, but the login still fails. The issue is new and has never occurred before in one year.

Has anyone faced the same issue?

Here is the error message:

Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open server "dbserver.database.windows.net" requested by the login.  The login failed.
   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at Microsoft.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool)
   at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
--- End of stack trace from previous location ---
   at Microsoft.Data.SqlClient.SqlRetryLogicProvider.ExecuteAsync(Object sender, Func`1 function, CancellationToken cancellationToken)
   at Microsoft.Data.SqlClient.SqlRetryLogicProvider.ExecuteAsync(Object sender, Func`1 function, CancellationToken cancellationToken)
   at Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.ReliableSqlConnection.<>c__DisplayClass30_0.<
Azure SQL Database
{count} votes

3 answers

Sort by: Most helpful
  1. Deepanshu katara 13,925 Reputation points MVP
    2024-01-16T10:32:01.3733333+00:00

    Hi , Please run the following query and let’s try to find evidence about the Azure SQL Database being throttled. SELECT *
    FROM sys.dm_db_resource_stats
    ORDER BY end_time DESC;

    If you see avg_log_write_percent is close or equal 100% you need to scale up the tier of the database. What about the DTU graph on the portal? Please verify if consumption of resources is reaching the limits of the tier since you added the data sync process. You can run the following query also to verify throttling occurs. SELECT
    (COUNT(end_time) - SUM(CASE WHEN avg_cpu_percent > 80 THEN 1 ELSE 0 END) * 1.0) / COUNT(end_time) AS 'CPU Fit Percent',
    (COUNT(end_time) - SUM(CASE WHEN avg_log_write_percent > 80 THEN 1 ELSE 0 END) * 1.0) / COUNT(end_time) AS 'Log Write Fit Percent',
    (COUNT(end_time) - SUM(CASE WHEN avg_data_io_percent > 80 THEN 1 ELSE 0 END) * 1.0) / COUNT(end_time) AS 'Physical Data Read Fit Percent'
    FROM sys.dm_db_resource_stats

    --service level objective (SLO) of 99.9% <= go to next tier When avg_log_write_percent is at 100% or near 100% then throttling occurs. Auto-pause only occurs if the database is an Azure Serverless database, the other Azure SQL flavors do not support auto-pause. On this document you will find ways to troubleshoot this error.https://learn.microsoft.com/en-us/azure/azure-sql/database/troubleshoot-common-errors-issues?view=azuresql#connection-timeout-expired-errors Please accept answer if it helps , Thanks

    0 comments No comments

  2. Feng, QingTang 20 Reputation points
    2024-01-16T10:43:38.19+00:00

    Hi Deepanshu,Thanks for your prompt reply. I did run the query but results show only 1% if I am not wrong.Any further trouble shooting recommendation?User's image


  3. Feng, QingTang 20 Reputation points
    2024-01-18T04:47:19.5333333+00:00

    Thanks for your help. The issue is resolved suddently. The root cause is still not clear. It is likely due to the IP address or fire wall rule setting in Azure Database

    0 comments No comments

Your answer

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