error 40 Could not open a connection to SQL Server

  • Hi,

    I have a problem in the connection to SQL Server 2014

    Description for my servers:

    2 server SQL 2014 and related with cluster failover with IP 10.8.130.125

    2 web server (IIS) and related with load network balancing with IP 10.8.130.250

    1 web application deployed in the 2 web server and the web.config is configured with this connection string:

    <add name="ConnectionString1" connectionString="Data Source=100.8.130.125; Initial Catalog=DbName; Password=xxxx;User ID=xxxx; Persist Security Info=True;" providerName="System.Data.SqlClient" />

    When I connect to this web application in the first time, it works normally, always when I display each web forms in this web application it works normally, but sometimes the connection is interrupted and this message is displayed :

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.(provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)

    but when I press refresh (F5) it return working.

    Please help me, because I am not understand what is this problem sometimes working normally and suddenly is interrupted.

    Imported Notice: my web application works normally, but sometimes display the error connection message.

  • I'm guessing you have a typo above, because you have 10. and 100. listed.

    If you get this sometimes, could the cluster be failing to the other node? Clusters do no get 100% uptime. When there is an issue, the failure requires the server to restart on the other node, which can be a 30s or so delay.

    Have you checked this? This is the most likely cause.

    Note, your code should a retry rather than erroring right away to the user.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply