I having trouble connecting to a SQL Server database on Azure. We've already added the IP address to the firewall exclusion list and the username/password work when connecting from other machines. We tried with both username/password and MFA.

What else could be causing the problem?

A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.) (Microsoft SQL Server, Error: 121)


2 Answers 2


try to connect choosing the proper user database here:

enter image description here

Maybe the user you are using is not able to connect to the master database.

Here is how database firewall rules work:


  • Unfortuantely that didn't help. But I'll give you an up-vote anyways because I've seen that work in the past when someone can't login from any machine. Feb 23, 2021 at 16:55

This most likely is related to network or latency where in connection is taking more time than expected.

Try increasing the connection time in SSMS to a larger value (60 seconds, for example):
(This is equivalent to Connection Timeout=60 in the connection string)

Connection Timeout

Update: also, check out this https://stackoverflow.com/questions/48978575/azure-sql-server-error-occurred-during-the-pre-login-handshake
Try the disconnect VPN advice

  • Connection time-out didn't help, though I've seen others try it with success. Feb 23, 2021 at 16:56
  • I hope you're wrong about the VPN because I think this machine is inside the company network and disconnecting isn't an option. Feb 23, 2021 at 16:56
  • @JonathanAllen and just to be 100% sure, it is SQL Server on a VM in Azure, not an Azure SQL DB, right ? Feb 24, 2021 at 14:35
  • I believe that it is Azure SQL DB, not a VM. Feb 24, 2021 at 18:33
  • @JonathanAllen maybe it has run out of sessions ? You know that Azure SQL DB has restrictions on how many sessions / connections it can handle, especially number of sessions running some requests (queries). Scale up Azure SQL DB to increase number of concurrent sessions, that could possibly help Feb 25, 2021 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.