Home
%3CLINGO-SUB%20id%3D%22lingo-sub-383279%22%20slang%3D%22en-US%22%3ENamed%20Pipes%20Provider%2C%20error%3A%2040%20-%20Could%20not%20open%20a%20connection%20to%20SQL%20Server%20(Microsoft%20SQL%20Server%2C%20Error%3A%20XXX)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-383279%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20May%2016%2C%202007%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3EThis%20error%20message%20is%20the%20most%20frequent%20error%20message%20when%20connecting%20to%20SQL%20Server.%20You%20see%20this%20error%20message%20when%20you%20use%20SqlClient.%20In%20SNAC%2C%20the%20error%20message%20is%20slightly%20differently%20as%20follows%3A%3C%2FP%3E%0A%20%20%3CP%3EC%3A%26gt%3Bosql%20-E%20-Syourserver%20%3CBR%20%2F%3E%20%5BSQL%20Native%20Client%5DNamed%20Pipes%20Provider%3A%20Could%20not%20open%20a%20connection%20to%20SQL%20Server%20%5Bxxx%5D.%20%3CBR%20%2F%3E%20%5BSQL%20Native%20Client%5DLogin%20timeout%20expired%3C%2FP%3E%0A%20%20%3CP%3EBasically%2C%20this%20error%20message%20just%20tell%20you%20that%20the%20client%20cannot%20make%20a%20connection%20to%20the%20server.%20It's%20equvalent%20to%20%22SQL%20Server%20does%20not%20exist%20or%20access%20denied%22%20in%20MDAC.%20Although%20the%20error%20message%20say%20about%20Named%20Pipe%20Provider%2C%20the%20issue%20does%20not%20have%20to%20be%20NP%20related.%20The%20reason%20is%20that%2C%20by%20default%2C%20the%20client%20stack%20try%20TCP%20and%20NP%20in%20order.%20If%20the%20connection%20attempt%20could%20not%20success%20with%20any%20of%20them%2C%20then%20NP%20is%20the%20last%20protocol%20tried%20and%20this%20is%20the%20error%20message%20to%20present%20to%20users.%3C%2FP%3E%0A%20%20%3CP%3EWhen%20users%20see%20this%20error%20message%2C%20sometimes%20xxx%20is%20omitted.%20But%20actually%2C%20xxx%20is%20the%20most%20important%20part%20of%20this%20error%20message.%20xxx%20is%20Windows%20error%20code%20and%20it%20gives%20customer%20hints%20about%20why%20the%20connection%20fails.%20Here%20are%20some%20error%20code%20users%20often%20see.%20I%20also%20explain%20the%20root%20cause%20and%20possible%20solutions%20here.%3C%2FP%3E%0A%20%20%3CP%3E1)%20xxx%3D53%20%3CBR%20%2F%3E%20winerr%2053%20means%20%22The%20network%20path%20was%20not%20found%22.%20If%20you%20got%20this%20message%2C%20it%20means%20the%20client%20stack%20cannot%20find%20the%20target%20machine.%20Here%20are%20possible%20reasons%20for%20this%20failure%2C%20%3CBR%20%2F%3E%20a)%20typo%20in%20the%20server%20name%2C%20or%20using%20%22%2F%22%20rather%20than%20%22%22%20between%20server%20name%20and%20instance%20name%2C%20e.g.%20%22myserver%2Fmyinst%22%20is%20not%20correct.%20%3CBR%20%2F%3E%20b)%20name%20resolution%20to%20the%20server%20name%20is%20not%20correct%2C%20%22ping%20-a%20yourserver%22%20would%20tell%20if%20that's%20the%20case%20%3CBR%20%2F%3E%20c)%20The%20server%20machine%20is%20firewall'ed%20and%20file%20sharing%20is%20not%20in%20the%20exception%20list.%20You%20need%20put%20%22File%20and%20Printer%20Sharing%22%20in%20exception.%3C%2FP%3E%0A%20%20%3CP%3E2)%20xxx%20%3D%201326%20%3CBR%20%2F%3E%20winerr%201326%20means%20%22Logon%20failure%3A%20unknown%20user%20name%20or%20bad%20password%22.%20When%20you%20get%20this%20error%20code%2C%20it%20means%20a)%20the%20client%20stack%20is%20able%20to%20reach%20the%20target%20machine%2C%20and%20b)%20the%20service%20account%20of%20the%20client%20application%20does%20not%20have%20enough%20credential%20to%20make%20a%20NP%20session%20to%20the%20server.%20NP%20is%20based%20on%20SMB%20(file%20sharing).%20The%20logon%20failure%20message%20represented%20by%20winerr%201326%20is%20from%20SMB%20layer%2C%20not%20SQL%20Server.%20You%20need%20to%20make%20sure%20you%20can%20make%20a%20file%20sharing%20to%20the%20server%20machine%20with%20the%20same%20service%20account.%26nbsp%3BIf%20you%20cannot%20make%20a%20file%20sharing%20between%20your%20server%20and%20your%20client%2C%20NP%20in%20SQL%20Server%20would%20not%20success.%20Try%20%22net%20use%22%20or%20%22Map%20Network%20Drive%22%20to%20check%20this.%20This%20often%20happens%20when%20server%20and%2For%20client%20is%20not%20on%20domain.%3C%2FP%3E%0A%20%20%3CP%3E3)%20xxx%20%3D%202%20%3CBR%20%2F%3E%20winerr%202%20means%20%22The%20system%20cannot%20find%20the%20file%20specified%22.%20This%20error%20message%20means%20the%20client%20can%20reach%20the%20server%20but%20there%20is%20no%20Named%20Pipe%20listener%20with%20specific%20pipe%20name%20on%20the%20target%20machine.%20It%20also%20means%20the%20account%20can%20have%20a%20file%20sharing%20session%20without%20a%20problem.Possible%20reasons%20are%3A%20%3CBR%20%2F%3E%20a)%20typo%20in%20instance%20name%20or%20wrong%20instance%20name.%20The%20instance%20name%20is%20not%20the%20one%20you%20are%20targeting.%20Note%20that%20for%20default%20instance%2C%20you%20shouldn't%20use%20MSSQLSERVER%20as%20instance%20name.%20%3CBR%20%2F%3E%20b)%20Target%20SQL%20Server%20is%20not%20running%20%3CBR%20%2F%3E%20c)%20Named%20Pipe%20is%20not%20enabled%20on%20the%20server.%20In%20this%20case%2C%20the%20SQL%20server%20is%20not%20listenning%20on%20the%20specific%20pipe%20name.%3C%2FP%3E%0A%20%20%3CP%3E4)%20xxx%20%3D%20233%20%3CBR%20%2F%3E%20winerr%20233%20means%20%22No%20process%20is%20on%20the%20other%20end%20of%20the%20pipe%22.%20If%20you%20see%20this%20error%2C%20it%20usually%20means%20you%20don't%20have%20sufficient%20credential%20to%20connect%20to%20the%20server%2C%20e.g%2C%20wrong%20user%20name%20and%2For%20password%20when%20you%20are%20using%20SQL%20authentication.%20The%20connection%20is%20closed%20by%20server%20before%20an%20error%20message%20is%20sent%20to%20the%20client.%3C%2FP%3E%0A%20%20%3CP%3EThere%20are%20other%20error%20code%20come%20with%20this%20error%20message%2C%20but%20they%20are%20not%20as%20often%20as%20the%20ones%20I%20just%20mentioned.%20When%20you%20see%20a%20new%20error%20code%2C%20just%20use%20%22net%20helpmsg%20xxx%22%20to%20get%20some%20information%20and%20see%20if%20you%20can%20figure%20out%20any%20suspecious%20issue.%3C%2FP%3E%0A%20%20%3CP%3EAs%20I%20have%20mentioned%2C%20this%20error%20message%20does%20not%20mean%20you%20have%20an%20issue%20with%20NP.%20You%20can%20do%20something%20unrelated%20to%20NP%20to%20eliminate%20this%20error%20message%2C%20e.g.%20%3CBR%20%2F%3E%20a)%20make%20sure%20target%20machine%20is%20accessible%20%3CBR%20%2F%3E%20b)%20target%20server%20is%20running%20%3CBR%20%2F%3E%20c)%20TCP%20protocol%20on%20the%20target%20instance%20is%20enabled%20%3CBR%20%2F%3E%20d)%20sqlservr.exe%20and%2For%20the%20TCP%20port%20that%20the%20server%20listens%20is%20on%20firewall%20exception%20if%20firewall%20is%20ON.%20%3CBR%20%2F%3E%20By%20doing%20this%2C%20you%20may%20success%20with%20TCP%20or%20have%20a%20failure%20with%20an%20error%20message%20related%20to%20TCP%20and%2For%20logon%20credential.%20This%20is%20because%20we%20success%20or%20fail%20with%20TCP%20protocol%20and%20does%20not%20even%20come%20to%20the%20point%20of%20using%20NP.%3C%2FP%3E%0A%20%20%3CP%3EXinwei%20Hong%2C%20SQL%20Server%20Protocols%20%3CBR%20%2F%3E%20Disclaimer%3A%20This%20posting%20is%20provided%20%22AS%20IS%22%20with%20no%20warranties%2C%20and%20confers%20no%20rights%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-383279%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20May%2016%2C%202007%20This%20error%20message%20is%20the%20most%20frequent%20error%20message%20when%20connecting%20to%20SQL%20Server.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-383279%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESQLServerProtocols%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft
First published on MSDN on May 16, 2007

This error message is the most frequent error message when connecting to SQL Server. You see this error message when you use SqlClient. In SNAC, the error message is slightly differently as follows:

C:>osql -E -Syourserver
[SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [xxx].
[SQL Native Client]Login timeout expired

Basically, this error message just tell you that the client cannot make a connection to the server. It's equvalent to "SQL Server does not exist or access denied" in MDAC. Although the error message say about Named Pipe Provider, the issue does not have to be NP related. The reason is that, by default, the client stack try TCP and NP in order. If the connection attempt could not success with any of them, then NP is the last protocol tried and this is the error message to present to users.

When users see this error message, sometimes xxx is omitted. But actually, xxx is the most important part of this error message. xxx is Windows error code and it gives customer hints about why the connection fails. Here are some error code users often see. I also explain the root cause and possible solutions here.

1) xxx=53
winerr 53 means "The network path was not found". If you got this message, it means the client stack cannot find the target machine. Here are possible reasons for this failure,
a) typo in the server name, or using "/" rather than "" between server name and instance name, e.g. "myserver/myinst" is not correct.
b) name resolution to the server name is not correct, "ping -a yourserver" would tell if that's the case
c) The server machine is firewall'ed and file sharing is not in the exception list. You need put "File and Printer Sharing" in exception.

2) xxx = 1326
winerr 1326 means "Logon failure: unknown user name or bad password". When you get this error code, it means a) the client stack is able to reach the target machine, and b) the service account of the client application does not have enough credential to make a NP session to the server. NP is based on SMB (file sharing). The logon failure message represented by winerr 1326 is from SMB layer, not SQL Server. You need to make sure you can make a file sharing to the server machine with the same service account. If you cannot make a file sharing between your server and your client, NP in SQL Server would not success. Try "net use" or "Map Network Drive" to check this. This often happens when server and/or client is not on domain.

3) xxx = 2
winerr 2 means "The system cannot find the file specified". This error message means the client can reach the server but there is no Named Pipe listener with specific pipe name on the target machine. It also means the account can have a file sharing session without a problem.Possible reasons are:
a) typo in instance name or wrong instance name. The instance name is not the one you are targeting. Note that for default instance, you shouldn't use MSSQLSERVER as instance name.
b) Target SQL Server is not running
c) Named Pipe is not enabled on the server. In this case, the SQL server is not listenning on the specific pipe name.

4) xxx = 233
winerr 233 means "No process is on the other end of the pipe". If you see this error, it usually means you don't have sufficient credential to connect to the server, e.g, wrong user name and/or password when you are using SQL authentication. The connection is closed by server before an error message is sent to the client.

There are other error code come with this error message, but they are not as often as the ones I just mentioned. When you see a new error code, just use "net helpmsg xxx" to get some information and see if you can figure out any suspecious issue.

As I have mentioned, this error message does not mean you have an issue with NP. You can do something unrelated to NP to eliminate this error message, e.g.
a) make sure target machine is accessible
b) target server is running
c) TCP protocol on the target instance is enabled
d) sqlservr.exe and/or the TCP port that the server listens is on firewall exception if firewall is ON.
By doing this, you may success with TCP or have a failure with an error message related to TCP and/or logon credential. This is because we success or fail with TCP protocol and does not even come to the point of using NP.

Xinwei Hong, SQL Server Protocols
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights