An existing connection was forcibly closed (error 10054)

Mahesh Kumar Babu Kummara 50 Reputation points
2023-09-23T17:03:41.31+00:00

My client was unable to connect to Azure SQL Database, attaching an error screenshot. User's image

Azure SQL Database
{count} votes

Accepted answer
  1. SSingh-MSFT 16,371 Reputation points Moderator
    2023-09-26T06:41:25.4233333+00:00

    Hi
    Mahesh Kumar Babu Kummara
    ,

    Welcome to Microsoft Q&A forum.

    In addition to the above answers, I suppose you are trying to connect to your Azure SQL Database through SSMS.

    As the error signifies pre-login handshake with error code: 10054.

    It could be due to one of the following reasons.

    1). For Hand-shake failure, this maybe due to transient network/connection error.

    Steps to resolve the same are:

    1. Make sure that TCP/IP is enabled as a client protocol on the application server. For more information, see Configure client protocols. On application servers where you don't have SQL tools installed, verify that TCP/IP is enabled by running cliconfg.exe (SQL Server Client Network utility).
    2. Check the application's connection string to make sure it's configured correctly. For example, make sure that the connection string specifies the correct port (1433) and fully qualified server name. See Get connection information.
    3. Try increasing the connection timeout value. We recommend using a connection timeout of at least 30 seconds.
    4. Test the connectivity between the application server and the Azure SQL Database by using SQL Server Management Studio (SSMS), a UDL file, ping, or telnet. For more information, see Troubleshooting connectivity issues and Diagnostics for connectivity issues.

    Note

    As a troubleshooting step, you can also test connectivity on a different client computer.

    1. As a best practice, make sure that the retry logic is in place. For more information about retry logic, see Troubleshoot transient faults and connection errors to SQL Database.

    2). For Error 10054, connection forcibly closed by host, this might be due to credential issue or when No matching TLS protocols exist between the client and the server. The issue occurs because the server and the client can't find a matching protocol (such as TLS 1.0 or TLS 1.1). A matching protocol is needed to complete the TLS handshake required to proceed with the connection.

    Solution could be:

    • Upgrade your SQL Server or your client providers to a version that supports TLS 1.2. For more information, see TLS 1.2 support for Microsoft SQL Server.
    • Ask your system administrators to temporarily enable TLS 1.0 or TLS 1.1 on both the client and the server computers by performing one of the following actions:

    There could be other SCENARIOS too which are mentioned here in the documentation which could help: https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/connect/tls-exist-connection-closed

    Please refer above 5 scenarios and solutions, kindly try and let us know if this helped.

    If not, do let us know so that we can for look for other options to unblock you.

    Awaiting your reply.

    Thank you.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Alberto Morillo 34,671 Reputation points MVP Volunteer Moderator
    2023-09-24T02:34:25.4566667+00:00

    This is usually an intermittent error, an error associated with pre-login handshakes caused by network delays or delays in certificate validation by the SqlClient driver. Pre-login handshake should ideally complete in 100-200 ms. Please consider collecting a network trace to verify the existence latencies greater than expected.

    1 person found this answer helpful.

  2. RahulRandive 10,486 Reputation points Volunteer Moderator
    2023-09-24T12:32:24.9866667+00:00

    Hi @Mahesh Kumar Babu Kummara

    The error "error occurred during pre-login handshake" occurs when there is a problem establishing a secure connection between the client and the server. This error can occur due to various reasons such as incorrect login credentials, firewall blocking the connection or network issue.

    You can try connecting to the database from the portal. If you can connect, the issue might be with your client machine

    User's image

    To troubleshoot this issue, you can try the following steps:

    1. Verify the login credentials: Ensure that the login credentials used to connect to the Azure SQL Database are correct.
    2. Check firewall settings: Ensure that the firewall settings are configured to allow incoming connections to the Azure SQL Database. You can check the firewall settings in the Azure portal under the "Firewalls and virtual networks" section
    3. Check if there are any network issues or firewall restrictions that could be causing the error during pre-login handshake.

    Thank you!

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.