An error has occurred while establishing a connection to the server when connecting to SQL server 2005, this failure may be caused by the fact that under default settings SQL server does not allow remote connection. ( provider: Named Pipes Provider, error: 40 - could not open a connection to SQL server. )
Fix/Workaround/Solution:
Step 1) Make sure SQL SERVER is up and the instance you try to connect is running.
Step 2) Your system Firewall should not block SQL Server port.
Step 3) Go to Computer Management >> Service and Application >> SQL Server 2005 Configuration >> Network Configuration
Enable TCP/IP protocol. Make sure that SQL SERVER port is by Default 1433.
Step 4) Now follow this KB Article of MSDN depending on your server : http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277
UPDATE : If above solution does not help refer the follow up post SQL SERVER - Fix : Error : 1326 Cannot connect to Database Server Error: 40 - Could not open a connection to SQL Server where additional issues with FIREWALL is explained with images.






Thank you, I would have never figured out that port enabling!
Hello , I did all the settings what you suggested but still it giving me same error messages
some of error messages are like..
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
hi,
thanks for your help.
have a nice day.
genious
Hi
I am using Asp.net and Sql Server.There is a situation where i need to connect to Remote Sql Server to get some values.Some values are from local Sqlserver.
If remote Sql server is down i get the Error Named Pipes Provider,Error:40
Is there a way i can handle this and just show empty strings if the remote sql server is down.
Please hlep me with this
Thanks
Kavya
Go to Computer Management >> Service and Application >> SQL Server 2005 Configuration >> Network Configuration
Can you please tell where this ‘Computer Management’ folder/file is?
Hi
I am not exactly sure which folder your’e asking about.
Thanks
Kavya
Hi
I also have one more Question
My Sql server DB is taking almost 54Gb of Physical Memory,and i see its not the Data but the LogFile,Can you let me know why is Log eating up the memory.
Thanks
Kavya
Hi all,
I also have the same problem.
I tried all the above given. But still the problem continues.
Go to Computer Management >> Service and Application >> SQL Server 2005 Configuration >> Network Configuration
How to go to Computer Management.
Please Help.
Thanks in Advance
Thanks, the problem in my case was the firewall, but I didn`t even bothered to open the port in Windows Firewall, because I have the ESET Smart Security, and I was recieving the same error, with the ESET Firewall on or off, I thought that the Windows Firewall is disabled allready, so it has no impact. I guess I was wrong. :)
we are getting the wrror like
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
ple give me the guidence to solve above error
Hello , I did all the settings what you suggested but still it giving me same error messages
some of error messages are like..
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Hey,
I too had same problem with my dev environment at home, but could figured it after banging my head. for some reason it did not work as suggested by many experts.
but dont worry, figured what was the problem at last………
the probelm is the Instance name from the client is not resolved, to do that follow the below shown steps.
1. navigate to C:\Windows\System32\drivers\etc
2. Open hosts file in notepad
3. add the entry at the end of line, as i did for example
192.168.131.65 KSSQLSRVR
192.168.131.65 KSSQLSRVR\SPDEV01
those were my instances i am tried to connect remotely
Hope this helps…
i think u got me!
Hi,
Thanx.. I got Solution.
Have Nice Time.
Hi,
Thanks…..
Hi i use sql server2000 but i recive this error :
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
can any body help me ?
Hey Mahmood
looks like your remote connection is not set properly.
As Dave mentioned earlier do the follwing and still doesnot work we will go from there.
Go to Computer Management >> Service and Application >> SQL Server 2005 Configuration >> Network Configuration
Enable TCP/IP protocol. Make sure that SQL SERVER port is by Default 1433.
Step 4) Now follow this KB Article of MSDN depending on your server :
http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277
hope this works,
I faced the same problem. I wasted almost a week. Finally I got the solution.
There are so many reasons behind the same problem.
One of then is as below.
There might be possoble you have defined aliases for the SQL server in your machine.
To check the alias :
Go to Control Panel -> Administrative Tools -> Computer Management : Open It
Expand Services And Application-> SQL Server Configuration Manager->SQL Native Client Configuration
Check Aliases Option Under.
If you find any aliases for the SQL Server that you are getting problem. Delete it for time being and test it.
For me it woeks hope that will help you too. Thanks.
Hi,
I have tried doing the enabling of Named Pipes and TCP/IP and VIA but still I get the same error…
Does this work with .sdf files?
Lejanson
I tried in so many ways to solve the following problem,
but still i am not getting the solution.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
this problem has encountered when using web parts in asp.net.
Thanks
Cherukuri
I have the same error( error 40 ), trying to connect to my SQL Server 2005. I use .net C# to make a web service (no web site!!) and trying to establish a connection locally in my PC. I cannot find a connection string too.
SqlConnection conn = new SqlConnection(???????????????);
Thanks you,
Apo
Fixed my problem with SQL Express.
Thanks,
RayG
I am trying to run asp.net 2.0 app against SQL Server 2000 and get error message
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Both app and SQL server are local
connection string is
“Data Source=(local);Initial Catalog=DBNAME;user id=sa;password=”
I have tried enabling TCPIP protocoll on 2005 server but it does not help.
Please help
Thanks
Vinay
hi, i am using biztalk server. I am getting the same problem when i am trying to deploy the biztalk server. I have applied your guidence. But my problem is not solved.
If you have any different idea please tell me.
thank you.
from
Gayathri
Thanks for u r suggestion. It work were well, i will tryed lost 10 days.
Hi Frnz,
i am using Microsoft SQL 2005, i am getting the same problem,
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
i enabled the TCP/IP, and also i changed the settings as mentioned in http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277 but no use.
could you please suggest me some other solution to solve this problem.
Thanks alot
that port thing worked like hell
thanks gave me some ideas.
I am trying to run windows application against SQL Server 2000 and get error message dot net 2005 is developement environment
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Both app and SQL server are local
connection string is
“”Data Source={m};Initial Catalog=dbname;Integrated Security = SSPI; Trusted_Connection=Yes;”
I have tried enabling TCPIP protocoll on 2005 server but it does not help.
Please help
Thanks
Manish
I tried your fix above for a situation I have with SQL and so far, I have still not been able to fix the problem. I get exactly the same error message and I have applied your ideas as well as the ideas on the microsoft link and so far, none has worked. Can you help please???
Better still, Can you also give me information on how to create a System Administrator Account for my SQL server. I mean add a user as a sysadmin and configure the account in such a way that user is able to access the DB
I am able to connect to SQL Server databases using SQL Server Client but not able to connect to any of the SQL server 2005 64bit databases from .NET code. I am getting following error message in .NET.
TCP/IP, named pipes and Shard Memory were already enabled in SQL Server 2005 network configuration and SQL Native client configuration. TCP/IP Default port 1433. SQL server, SQL agent and Browser serveices were running.
Error Message :
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Following is the connection string that developers were using using.
Persist Security Info=False;Integrated Security=SSPI;database=omhq537e;server=INV_PROD
Any suggestions about how to resolve this issue?
THIS WEBSITE VERYUSEFUL FOR ME
This solution works for me
1. navigate to C:\Windows\System32\drivers\etc
2. Open hosts file in notepad
3. add the entry at the end of line, as i did for example
192.168.131.65 KSSQLSRVR
192.168.131.65 KSSQLSRVR\SPDEV01
Thanks to Purushotam
I try this but problem is still persist
I have the same problem still, I tried all the suggestions but still no fix. I also realise that the 2 servers are on 2 different domain. I presume due to this my issue remains unresolved
I also had that problem but it was caused by the DNS suffix Search List on the server set to an ip address instead of the domain name, so my app was looking for server.111.222.111.222 instead of server.domain.name
Thanks for helping me look in the right general direction anyway.
I am facing the same proble, even after I apply all the solution suggested above,
Please if any one hase extra information that might help,save my life …
note:
I have the web application on a machine with SQL server installed and I connect to a database on othe machine
If you changed your connectionstrings in your web.config, verrify that the information is correct.
I use a different synthax for the production server and my development server and I accidently copied the web.config file from the production server to my development server and there was my error.
Have a great day and I hope that this will help someone!
hi all
i hv tried all solution for the errr
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
at the time of sql server 2000 connection
and it working fine with sql server 2005 express
but no exact solution is not getting
plz help me
I am trying to run windows application against SQL Server 2000 and get error message dot net 2005 is developement environment
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
Thanx Mannn things worked ….
Hi,
i am trying to connect my local server in sql server 2005.
every time fails raising error “An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (.Net SqlClient Data Provider)”
tried with net start mssqlserver - command gives service is invalid
any help…
SQL Server 2005 connecting from MS VS 2005 app gives no problem, but SQL Server 2005 connecting from MS VS 2008 app gives the exact problem and seemingly no one knows the fix, not even Microsoft!
[...] SQL SERVER - Fix : Error : 40 - could not open a connection to SQL server [...]
For those that might not have figured it out yet, Computer Management refers to the same place as either 1) right-clicking “My Computer” and hitting “Properties”, or 2) going to Start, Run, and typing “compmgmt.msc” (no quotes).
Actually, sorry, I meant right-clicking “My Computer” clicking “Manage”, not “Properties”.
Hi,
We are using plesk 8.3 and using remote sql server connection ,couple of days ago database conection was working fine. Now we are facing an unknown issue..
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
If i use the same connection string in my local Asp.net application i am able to connect to remote database but when i try in plesk it return error. Even i am able to connect using MS SQL management studio and SQL Manager Lite .
What could be the issue . Please help us ASAP.
@ Pallav,
Try checking these things,
1. Check SQL Server Browser service is running and is kept in automatic Start mode.
This can be checked by.
Start -> run- > type services.msc -> enter -> check for SQL Server browser service, and start if it is not running.
2. Under SQL Server Surface Area Configuration check if SQL Server allows remote connections, by default it will allow only local connections.
This can be checked by,
Login to Server ( Where SQL Server is installed )
Start-> allprograms -> Microsoft SQL Server 2005->Configuration Tools -> SQL Server Surface Area configuration -> Click Server Area configuration for Services and connections ->choose your sql server - remote connections -> on the right side, choose allow remote connections to this server and choose both TCP/IP and NamedPipes.
3. Or Check your Windows Firewall, if SQL Server is being blocked, try to disable Firewall and then connect if it works then problem could be WIndows firewall.
Hope this helps.
Imran.
I am getting the same error while publishing the application. It runs fine on the local IIS but does not publish it in a local directory so that i can upload it a production server. Any suggestions?
[...] SQL SERVER - Fix : Error : 40 - could not open a connection to SQL server [...]
After following steps, i am getting the error called “Microsoft Sql Server error : 2″
So what to do?
[...] and I have already posted few solutions on this error, see if you can find your solution here SQL SERVER - Fix : Error : 40 - could not open a connection to SQL server SQL SERVER - Fix : Error : 1326 Cannot connect to Database Server Error: 40 - Could not open a [...]
When i go into control panel a try to uninstall a program it tells me that the file log can’t be found. I have even tried to restore the computer and it tells me it worked fine until it restarts and then it says it didn’t restore properly.. Can u help me?
Jennifer
hai
Thanks a lot
gr8
regards
tkt
Hi Dude
Thanks for the info on port changing. It solved my problems that I had for weeks. Thanks.
ultimate reply
thks
gagan
I have getting the same error message and I tried everything in this article unfortunately t wasn’t working.
Finally I make the following change and it works fine:
Visual Studio 2008 Tools Menu>>Options>>Database Tools…there was a Sql-Server instance specified to alias of the sql-Server instance and I delete it and it works fine.
I hope this helps
Cheers,
Ephrem
Step 3 in the suggested workaround above solved my problem. The defalut SQL Server Port was blank. I changed it to 1433.
Step 3) Go to Computer Management >> Service and Application >> SQL Server 2005 Configuration >> Network Configuration
Enable TCP/IP protocol. Make sure that SQL SERVER port is by Default 1433.
Hi we u get the error sql server does not allow remote connections then go to sql surface area configuration and there select allow remote connections TCP/IP and named Pipes and then restart SQL server both in surface area configuration and sql server for restatating sql first u need to connect to u windows authenication and then right click on the server name and click restart and then try to connect.
NOTE: Remote connections will allow only sql authentication and windows authentictaion cannot be used
I am getting the following error and have tried all the above workarounds but my SQLServer & SQLServer Agent are still refusing to run. the error msg i am getting is below: “an error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error:2).
Please assist.
I had the same error. Mine had to do with user permissions. The SQLServer2005 security group was created locally on the server and not at the domain level. I created a new group in AD, then added that AD group to the local group on the server. Everything is working now.
Hello, I have a related problem installing a new instance of SQL SERVER 2005, when it is installing the database engine it says that there are no process on the other side of the named pipes and I can’t configure anything because the instance is not installed yet, someone have any idea. Thanks.
Hi. I am posting my SQL issue that is driving me crazy for the past few days.
Error: ” An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2) ”
I get this message when I try to open SQL Server Management Studio. I have SQL Server 2005 (SP 2) on my new Windows Vista PC. I went to Services to check if teh MSSQLSEVER is running only to find that it is stopped and I cannot get it started, and also the other SQL Sever services except SQL Browsing.
Below is the last part of the ErrorLog if this givesd any idea:
—————————————–
2008-12-29 12:06:15.37 Server Error: 17182, Severity: 16, State: 1.
2008-12-29 12:06:15.37 Server TDSSNIClient initialization failed with error 0×2, status code 0×80.
2008-12-29 12:06:15.37 Server Error: 17182, Severity: 16, State: 1.
2008-12-29 12:06:15.37 Server TDSSNIClient initialization failed with error 0×2, status code 0×1.
2008-12-29 12:06:15.37 Server Error: 17826, Severity: 18, State: 3.
2008-12-29 12:06:15.37 Server Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
2008-12-29 12:06:15.37 Server Error: 17120, Severity: 16, State: 1.
2008-12-29 12:06:15.37 Server SQL Server could not spawn FRunCM thread. Check the SQL Server error log and the Windows event logs for information about possible related problems.
—————————————–
I did some basic troubleshooting like enabling Named Pipes, disabeling VIA protocols etc but no luck yet.
I found few articles with a “solution ” to this error online but none specify steps in orderly fashion where I get lost. Any help in this in this regard would be greatly appreciated.
Thanks,
Sara
I tried lot of solutions for this problem and atlast the following solution worked for me.
Added and Entry of IP of the Server in the C:\Windows\System32\drivers\etc
Thank You Purushotam