The reason for this common error is that by default MS SQL Server runs in “Windows Authentication mode”. And you will need to change it to “SQL Server and Windows Authentication mode” by following the steps below: Launch SQL Server Management Studio. Log into your SQL Server using Windows Authentication.
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.
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.
This worked for me.
Running the following command worked for me:
netsh Winsock reset
Seen at https://serverfault.com/a/487139/250527
I experienced this error when running some very memory-expensive processes. When the system started to run short of memory, I begun to notice this kind of error. I had to change the algorithm in order to make a better use of RAM.
To be noted that while some threads threw this exception, some other threw:
System.Data.SqlClient.SqlException (0x80131904): Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=43606; handshake=560; ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
Both problems disappeared after the system was changed so that it could run using less RAM.
I had the same problem, I was storing session data in the database, the connection string had Encrypt=True in it, which I assume told the sql client to connect to the server in secure (SSL) mode, removing this helped!
You might want to check a few things:
You production server allows remote connections. (possible that someone turned this off, especially if you have a DBA)
Check your connection string. Sometimes if you are using an ip address or server name this will cause this error. Try both.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With