A connection was successfully established with the server, but then an error occurred during pre-login handshake (provider-TCP Provider; error-0

Paraman

Member
Joined
Oct 19, 2024
Messages
5
Programming Experience
10+
Hi, from my C# windows application, when I try to connect with my SQL Database, located in my website, I receive the following error message

A connection was successfully established with the server, but then an error occurred during pre-login handshake (provider-TCP Provider; error-0 An existing connection was forcibly closed by the remote host.)

My Connection String
Connection String:
String MyDBCon_1 = "Server=xxx.xxx.xxx.xx, xxxx; User Id=MyUserID; Password=MyPsWord; Database=MyDataBaseName;";
 
What happens when you temporarily disable all your anti-virus software?

Have you verified that both your machine as well as the database server is using the latest SSL/TLS, and has disabled obsolete SSL/TLS versions? I ask because I think we briefly saw this last year when half our machines were still using TLS 1.1 while the other half had finally disabled it.
 
Also, if you are using .NET Framework 4.5.2 or older, it defaults to a TLS version that is obsolete. Make sure you are using 4.6.2 or higher. I recommend 4.8.1.
 
Back
Top Bottom