Solved

Named Pipes Provider, error: 40 - Could not open a connection to SQL Server

Posted on 2014-01-22
6
3,081 Views
Last Modified: 2014-01-24
Been dealing with this problem all day and nothing works.
We are using SQL 2008 on a Windows 2003 server.
Everything had been working fine until a few days ago when we renewed the certificate on the web server (I don't think this has anything to do with it).
I get the error when trying to use my web application:

Server Error in '/SMA13' Application.

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)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: 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)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SqlException (0x80131904): 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)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5063578
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +341
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +239
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
   System.Data.SqlClient.SqlConnection.Open() +125
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +123
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +319
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +92
   Login.Page_Load(Object sender, EventArgs e) +105
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1016


I thought it might be the connection between my web server and SQL server but I could ping them fine.
I even tried the telnet 1433 method and that connected fine.
TCP/IP and Named Pipes are enabled.
I even tried turning Named Pipes off, that didn't work.
I tried putting in the IP address itself in the connection string and that did not work.
EVERYTHING works perfect in development but when we try it on the webserver we get the error.
0
Comment
Question by:rr4406pak
6 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 39800410
Something to try ... use the fully qualified server name in your connection string, e.g.  servername.domain.net  instead of just servername.
0
 

Author Comment

by:rr4406pak
ID: 39800437
Yep, we tried that. Still same error. This is the hardest problem I've ever come across in dealing with SQL.
0
 
LVL 16

Expert Comment

by:Surendra Nath
ID: 39800450
it may not be a issue with SQL Server...
It may be an issue with the IIS

Can you try to write a desktop application (small one) to test if the SQL is working fine from the web server

if it is, then the changes that you did on the webserver is what affecting your SQL connection roll back the changes and see if that solves the issue.
0
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 

Author Comment

by:rr4406pak
ID: 39800778
Maybe we should bring the web server and the SQL server down and restart them for the heck of it?
Would there be any particular order to bring the servers back up? SQL server first?
We're running out of ideas...
0
 
LVL 38

Accepted Solution

by:
Jim P. earned 500 total points
ID: 39801695
Would there be any particular order to bring the servers back up? SQL server first?

I would do the SQL Server first. Then the web server.  

Another question, did any of the DC's change? Or reboot?

Named Pipes works by going to one DC and then the DC sends a token to the SQL Server to say "Yes you can give data to the Server/App/User." If tha DC is rebooted or loses connections the token becomes invalid.

With TCP/IP the web server gives it's SID to the SQL Server and then SQL goes to find a DC and says "Does this Server/App/User exist and not lying to me?" Whichever DC says "Yes" or "No" then SQL sends the data. If the session is broken for whatever reason the SQL can re-request the SID/credentials and then re-validate from any available DC.

I discourage NP and turn it off during setup of a SQL Server installation out of habit.
0
 

Author Comment

by:rr4406pak
ID: 39806948
Solved the problem.
It turns out it was related to updating the SSL certificate on the web server.
It seems that once you install a new certificate something has to "sync" between the web server and its database server(s).
Once I brought both web and database servers down, then brought the database servers up first, then the web server last, it all started working again.
So be careful when updating your server certificates!
Thanks!
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question