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

前端 未结 24 3008
無奈伤痛
無奈伤痛 2020-11-27 03:37

I am getting following error when i am trying to connect Production DB from Local Environment.

I was able to connect Production DB before, but suddenly i am getting f

相关标签:
24条回答
  • 2020-11-27 04:11

    In my case it was:

    Persist Security Info=True;

    in my connection string that needed to be removed. Once I did that I no longer had issues.

    0 讨论(0)
  • 2020-11-27 04:12

    Same problem here and no answers listed here worked, nor any solutions I could find online. The issue started shortly after Windows 10 anniversary update got applied on my dev PC and only affected my old SQL Server 2005 instance. I was not able to connect to the instance via my Web Applications or even using Sql Management Studio.

    For what it's worth, this is what resolved it for me:

    1. Open SQL Server Configuration Manager (depending on what version of SQL Server you're running):

      • C:\Windows\SysWOW64\SQLServerManager.msc
      • C:\Windows\SysWOW64\SQLServerManager10.msc OR
      • C:\Windows\SysWOW64\SQLServerManager12.msc OR
      • etc
    2. Select SQL Server Services

    3. Locate the troubled service and view Properties

      • eg SQL Server (SQL2005) in my case
    4. In the Log On tab, change the "Built-in account" to "Network Service"

    Which is almost what this random solution said: http://www.kutayzorlu.com/operating-systems/linux-unix-redhat-debian-ubuntu-opensuse-centos/general-server-administrating/error-fixed-a-connection-was-successfully-established-with-the-server-but-then-an-error-occurred-during-the-pre-login-handshake-12405.html

    I chose Network Service for no reason at all. Mine was already configured to use Local System. This security doesn't matter to me as it was only problematic on my Local development machine, only accessed locally. I can't advise why this works, but it did.

    0 讨论(0)
  • 2020-11-27 04:14

    Had the same problem from many days. I had to explicitly add TLS1.2 support in my core project to address this error and it worked fine. ( ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;)

    See below link for more details (thanks to author Usman Khurshid) https://www.itechtics.com/connection-successfully-established-error-occured-pre-login-handshake/

    0 讨论(0)
  • 2020-11-27 04:15

    If you are connecting to an old SQL Server:

    Switch from System.Data.SqlClient.SqlConnection to System.Data.OleDb.OleDbConnection

    Use an OleDb connection string:

    <connectionStrings>
    <add name="Northwind" connectionString="Provider=SQLOLEDB.1; Data Source=MyServer; Initial Catalog=Northwind;  Persist Security Info=True; User ID=abc; Password=xyz;" providerName="System.Data.OleDb" />
    </connectionStrings>
    
    0 讨论(0)
  • 2020-11-27 04:15

    In my case, Re-enabling TLS 1.0 in the DB server resolved this issue.

    0 讨论(0)
  • 2020-11-27 04:16

    I tried many solutions in the past month, none has worked. The problem is the Production DB is within a VPN and somehow the ISP provider thinks the HTTP connection is not secure. However, I was able to connect to the same Production DB from SSMS (uses TCP).

    My solution: use the mobile phone as a hotspot and use mobile data instead of my office/home Wi-Fi.

    0 讨论(0)
提交回复
热议问题