Solved

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

Posted on 2014-01-22
6
3,156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

624 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