A connection was successfully established with the server, but then an error occurred during the pre-login handshake

Solution 1:

Solution

1) Clean your VS.Net Solution

2) Rebuild Project.

3) Reset IIS

4) Run the project again.

Basically that solved my problem, but in my case i was not getting this error and suddenly my local environment starts giving me above error, so may be that trick work for me.

Solution 2:

In my case this error occurred with dot net core and Microsoft.Data.SqlClient. The solution was to add ;TrustServerCertificate=true to the end of the connection string.

Solution 3:

  • Save your work,
  • Close Visual Studio, then
  • Re-open your project

This worked for me.

Solution 4:

Running the following command worked for me:

netsh Winsock reset

Seen at https://serverfault.com/a/487139/250527