SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server.

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.

Reference : Pinal Dave (http://blog.SQLAuthority.com)

About these ads

169 thoughts on “SQL SERVER – Fix : Error : 40 – could not open a connection to SQL server.

    • i have install oracle form builder 6i in my computer . It work well but when i change my computer name its turn error just like this
      ORA-12514: Message 12514 not found ; product = RDBM580; facility =ORA

  1. 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)

    • 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 ppes provider,error:40-could npt open a connecton to sql server)

    • 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. this is the error with sql server 2008. what should i do for this?

  2. 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

  3. Go to Computer Management >> Service and Application >> SQL Server 2005 Configuration >> Network Configuration

    Can you please tell where this ‘Computer Management’ folder/file is?

    • computer management is nothing but
      “start -> All programs -> Sql Server -> Configuration Tolls ->Sql Server Configuration manager”

      when u click on “Sql Server Configuration manager” , a window will open for u .In that window select “Sql Server Network Configuration”,there u will find “protocals or sqlserver”.click on it u will get list of protocals

      • computer management is nothing but
        “start -> All programs -> Sql Server -> Configuration Tolls ->Sql Server Configuration manager”

        when u click on “Sql Server Configuration manager” , a window will open for u .In that window select “Sql Server Network Configuration”,there u will find “protocals or sqlserver”.click on it u will get list of protocals

  4. 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,

      I Guess during installation setup ask you select a server type whether
      1. Developer machine (minimal amt. of memory)
      2. Server Machine (medium memory Usage)
      3.Dedicated MySql Server Machine (Utilize up to all available memory)

      You can re configure this seting using MySql Server Instance Configuration Wizard.

      Thanks and Tell if this info. is useful.

  5. 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

  6. 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. :)

  7. 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

  8. 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)

  9. 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!

  10. 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 ?

  11. 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,

  12. 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.

  13. 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

  14. 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

  15. 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

  16. 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

  17. 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

  18. 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.

  19. 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

  20. 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???

  21. 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

  22. 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?

  23. 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

  24. 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

  25. 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.

  26. 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

  27. 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!

  28. 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

    • hi,
      did u get any solution for ur problem..now am facing same problem..could u pls tell me,how to rectify that error
      (Os-Vista)

      with sql 2000 its fine..when am running with sql-2005 am facing this error(Os-Vista,server=server/SQLEXPRESS)

  29. 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)

    • hi,
      did u get any solution for ur problem..now am facing same problem..could u pls tell me,how to rectify that error
      (Os-Vista)

  30. 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…

  31. 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!

  32. Pingback: SQL SERVER - Fix : Error : 1326 Cannot connect to Database Server Error: 40 - Could not open a connection to SQL Server Journey to SQL Authority with Pinal Dave

  33. 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).

  34. 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.

  35. @ 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.

  36. 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?

  37. Pingback: SQL SERVER - Fix : Error : 40 - could not open a connection to SQL server - Fix Connection Problems of SQL Server Journey to SQL Authority with Pinal Dave

  38. Pingback: SQL SERVER - FIX : ERROR : Could Not Connect to SQL Server - TDSSNIClient initialization failed with error 0×7e, status code Journey to SQL Authority with Pinal Dave

  39. 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

  40. 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

  41. 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.

  42. 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

  43. 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.

  44. 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.

  45. 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.

  46. 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 0x2, status code 0x80.
    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 0x2, status code 0x1.
    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

  47. 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

  48. I can connect to my SQL Server 2000 from all servers except one Windows 2003 server. When trying to use ODBC connection, it produces Error 53, 17 and 10065. There is no firewall preventing oubound traffic for the web server. What could be preventing the outbound traffic to the SQL Server.

    Thanks!

  49. Hi, everybody must concentrate on Connection String in WebConfig file before proceeding. Sometime a little problem you don’t recognize. In my case it happened. If you r using Visual Studio it’s better you can put SqlDataSource control on ur ASP.NET page & try to connect Sql Server instance you want to use through it & after successful tested connection use the connection string created by it. It’s not a big thing I told you but you miss tiny things sometime.I hope it might be helpful for somebody.

  50. Hi

    I’m facing a problem while accessing a SQL Server 2005 (it has been upgrated from 2000) from a SQL Server 2005 reporting service which is running in a Windows XP machine.

    I get the following error

    An error has occurred during report processing.
    Cannot create a connection to data source ‘DataTest’.
    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)

    The same thing works fine i create the datasource from Visual Studio and try to preview the report it works fine, but it throws an above mentioned error while it is accessed from the Reporting server site.

    I tried all the solutions mentioned above.

    Please help me.

  51. Thanks very much for the solution to the error 40 problem. I
    recently moved to xp pro and sql server 2005. This fixed my problem and I am most appreciative.

    Michael David Simmons

  52. For me, the error 40 problem occurred when I was running the ASP.NET SQL Server Setup Wizard.

    My PC is named WARGAMES-PC. I have two versions of SQL Server running on it 2005 and Express.

    The one I want to install the database in is called MSSMLBIZ. I found this name in several places, one of which was using VS2008 Add Connection, which incidentally didn’t have any problems connecting to the databases.

    The solution for me was to put WARGAMES-PC\MSSMLBIZ as the Server name. I then picked aspnetdb as the database.

    Another hour wasted having to learn stupid configuration tricks because there is no STANDARD!

  53. I have a SQL Server 2000 running on Win2k3. I uninstalled SharePoint so
    I could install Reporting Services and I upgraded to MDAC 2.8. I tried
    connecting to SQL locally on the Enterprise Manager on the machine but
    I get this error: “Server does not exist or access is denied.”

    The odd thing is that I can connect to that SQL Server from other
    remote machines through Enterprise Manager, I just can’t connect
    locally. All help is appreciated.

    Thanks in advance..

  54. Hi All,
    I was able to solve it. We just need to uncheck the Encryption support in Client Network Utility. But now I am not able to connect to other sql server DB on other machine, but still I can’t connect to this DB from other machinet. I am getting error
    “Msg 17, Level 16, State 1
    [ODBC SQL Server Driver][DBNETLIB]Sql Server does not exist of access denied

    Please help me to troubleshoot this.
    Thanks
    Mithalesh

  55. I tried lot of solutions for this problem and finally the following solution worked for me.

    Added and Entry of IP of the Server in the
    1. 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

    Thank You Purushotam

  56. I was playing with System Center Virtual Machine Manager on a Test server running Windows Server 2008 and SQL Server 2008 64 bit. It was working well in January 2009 and then I powered down the Server.

    When I returned to this server after a few months of inactivity, it forced me to change (Admin) password and soon after that I found SQL Server 2008 and SCVMM were not running. I was getting Logon failure and was getting ready to reinstall both.

    Luckily a google search lead me to your article. I followed your directions and sure enough the SQL Server Service was in a ‘Stopped condition’. It refused to restart till I replaced the Password in the ‘Logon’ Tab of the Service. SCVMM was also in stopped condition because it requires SQL Server 2008 to be running.

    Now both are running fine.

    Thanks a lot, you saved me a lot of time!

    Dominic

  57. We are working on PHP 5.2.9, MSSQLServer 05, IIS, Win XP server.
    We are sucessfull in making the website running without any issues for 2 months, we had another website and database installed on the same server.

    Now at a time span of 2 hours or so, we are getting the issue of “Unable to connect to the database server” from the website. After sometime, refreshing will make it working.

    Dont know whats happening over here. Website will be down for few minutes and then starts working without doing anything.

    Why is this happening? can anyone throw some light on this?

    Please let me know if you had same kind of issue and have solutions for this..

    Thanks

  58. Hi Pinal,

    I created a linked server on sql server 2005 express edition and tried to access linked server which is sql server 2000 enterprise in my case. But, Infortunately I am not able to connect..I am getting following error…

    Server: Msg 65535, Level 16, State 1, Line 0
    SQL Network Interfaces: Server doesn’t support requested protocol [xFFFFFFFF].
    OLE DB provider “SQLNCLI” for linked server “CentralDB” returned message “Login timeout expired”.
    OLE DB provider “SQLNCLI” for linked server “CentralDB” returned 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.”.

    I have checked…Browser is working…remote connection is enabled and their is not problem from firewall. Still I am getting this error. Though If I create a link server vice versa I am able to do so. I mean from sql server2000 to sql server 2005 express edition.

    Let me know if you need any additional information.

    Please help.

    Thank you,
    Mithalesh Gupta

  59. Hi to All,

    Its a very generous problem, which may have many solutions. But as we have witnessed so many user saying that they have tried everything.

    What solved my problem is..

    I upgraded sql server 2000 from sp2 to SP4 and if you already have sp4 on sql server 2000 then run Instcat.sql. As per my experience I can assure you this will work for sure, if you are exhausted with all the other workarounds.

    Thanks,
    Mithalesh

  60. Thanks a lot for this post, Pinaldave. The solutions you forwarded worked just fine on our instances, and for that, we deeply appreciate it!

  61. i’ve been trying this for days and i just dont know what the problem
    is …

    im using:

    private string conns = “Data Source = ‘MOI-PC/SQLEXPRESS;Initial
    Catalog = Project; User ID = sa; Password = madurai'; Connect Timeout
    = 60;”;

    SqlConnection conn = new SqlConnection(conns);
    conn.ConnectionString = conns;

    try
    {
    conn.Open();
    }
    catch (Exception ex)
    {

    MessageBox.Show(“ERROR \n”+ex.Message);
    }

    All i get is ..

    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)

    I use Windows Vista Ultimate SP2, SQL server 2005 SP3 and Visual
    Studio 2005
    sql server is configured to accept remote connections …. both tcp/ip
    n named pipes
    my sql browser is running ….

    any help would be greatly appreciated!!

  62. I am using sql server 2005 enterprize on the system having windows server 2003 having LIVE IP….. i want to connect 5 other systems having windows xp and sqlserver 2005 client installed……. 3 of my systems are successfully connected to the server but unfortunately 2 of the systems are not…… i dont what is the real cause of this error 40….. I applied all the settings on the server and seached alot on the internet….. but invain……..

  63. I tried lot of solutions for this problem.
    For me also below solution worked.Added and Entry of IP of the Server in the
    1. C:\Windows\System32\drivers\etc
    2. Open hosts file in notepad
    3. add the entry at the end of line,
    ip address then alias name then server name

    Thanks for all and special Thanks to Purushotham

  64. I had same problem – I tried all troubleshoutings from web and not works… but…

    My situation was little “curious”, but maybe helps: I forgot change my “office” web.config on parts, where should session stored (We are storing session in DB and I didn’t have changed settings to “InProc”)…

  65. i have a problem on connecting to sql server 2005. but when i turn off the firewall of my server, my application will run well. when the firewall on my server is turned on, i got this problem….

    Aconnection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because the connected host has failed to respond.

    i hope anybody can explain me about this problem……

    thanks a lot..

  66. Dear All,
    I am facing an error while configuring Sharepoint (WSS 3.0 SP1) with SQL SERVER 2005. I am not able to establish a connection with the SQL SERVER 2005. It is showing the following error while trying to create new database from “SharePoint Products and Configuration Wizard”

    ERR1 —>
    An exception of type System.Data.SqlClient.SqlException was thrown. Additional exception information: 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: SQL Network Interfaces, error: 25 – Connection string is not valid)
    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: SQL Network Interfaces, error: 25 – Connection string is not valid)

    ERR2 –>

    Task configdb validation threw an exception

    ERR3 –>

    An exception of type Microsoft.SharePoint.PostSetupConfiguration.PostSetupConfigurationTaskException was thrown. Additional exception information: Failed to connect to the database server or the database name does not exist. Ensure the database server exists, is a Sql server, and that you have the appropriate permissions to access the database server. To diagnose the problem, review the extended error information located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\LOGS\PSCDiagnostics_3_3_2010_18_57_25_62_1244457103.log. Please consult the SharePoint Products and Technologies Configuration Wizard help for additional information regarding database server security configuration and network access.
    Microsoft.SharePoint.PostSetupConfiguration.PostSetupConfigurationTaskException: Exception of type ‘Microsoft.SharePoint.PostSetupConfiguration.PostSetupConfigurationTaskException’ was thrown.

    Somebody Please help me.

    Thanks.

  67. I am having this problem with a user and noticed that the workstation only had framework 1.1 installed. I am going to have 3.5 installed and see if this corrects the problem. HTH

  68. Dear All,

    created a Data Base file using SQL server connection configured as PRADEEP/SQLExpress in Visual Studio 2005 application which is my computer name. When the application is deployed as .exe file and installed in another computer with database file copied to MSQL folder..Will it be working…

  69. i want to deploy my c# project, i want to install this project to my Laptop, my laptop has no visual studio and sql server, so how can I set my connection string, how will run my project without sql server, and where my database files are placed. pls help me…

  70. sir,i am unable to connect with sql datasource with asp.net through windows authentication so what shall i do please give me the answer as soon as possible

  71. Hi..

    I have error like this but I am using microsoft server 2008 for thet I could’t find the settings for that.

    Can anyone help me ???

    Thanks..

  72. hi,
    i hav 6 sql named servers, 1 is local and others 5 are with read only access. at debugging time connection works fine.
    but after deplyoment my local server is responding bt other five gives errors no 40, provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)

    thanx for any help.

  73. hi,
    i have a problem to connect with the servers database and i am working on the client machine and also what is the connection string for connecting to the server’s database….

  74. If you verified the for following settings (steps)-

    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.

    Ensure that the logon Credentials for the various SQL services are set correctly. Also verify that the services have been started.

  75. i am using sql server 2008.while establishing a connection to local server TITLE: Connect to Database Engine
    ——————————

    Cannot connect to geetha.

    ——————————
    ADDITIONAL INFORMATION:

    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)

    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=2&LinkId=20476
    i am not getting this error.please help me.

  76. am using sql 2005..error 2 and 40 shows wen am trying to login to sql server mngmt studio..as u said, i enabled tcp/ip and named pipes…but i cant star MSSQL SERVER.Error came as
    1)does not respond in timely fashion
    after adjusting the time to 6000,again this error shows..
    plz giv me a working solution solution

    • @Abhijit

      If it is just a laptop and no network involved in it

      1. Check FireWall is turned on, if On, turn it off and try to test connecting to SQL Server Instance.

      2. If you are using Windows Vista / Windows 7, Try opening SQL Server Management Studio as Run AS Administrator.

      3. Check if SQL Server Service is actually Started ( You can check this at couple of places, 1)SQL Server Configuration Manager, 2 Management Services ( Start – Run – type Services.msc and hit enter)

      4. Check if you are connecting to correct SQL Server instance name.
      If you have installed SQL Server as Default instance ( you have not provided any name to SQL Server during installation), then Name of SQL Server will be Computer Name. If you have Provided SQL Server a name during installation, then SQL Server Instance to which you will connect would be COMPUTERNAME/SQL Server Name,

      Example:
      Default Instance:
      Say, your computer name is COMP1 and you have given no name during installation, then Default instance of SQL Server would be : COMP1

      Named Instance:
      Say, your computer name is COMP1 and during SQL Server installation, you have given a name SQLPROD1, then SQL Server instance name would be COMP1\SQLPROD1 (Remember its a backward slash)

      ~Peace.

      • I spent 24 hrs with this error on a laptop with local database – finally replacing (local) in SQL Management Studio with [machine_name]\SQLEXPRESS worked. What fooled me is that the SQLEXPRESS name did not appear after a browse for instances – always before all available SQLSERVER instances had been listed. Anyway, typing in the name worked for me.

  77. Please help me i am using SQL express for another software run it automatically fatch the IP adress i dont Know from where its is not the IP of same machine where i install but when i run same software to another machine i get diffrent IP please help me out how i connect my machine to sql express 2005 thankks

  78. sir im using a vb.net and sql server 2005 ..here my scenario
    im 2 computer and pc1 and pc2 i have my database in pc1 and i want to get my data in pc1 to pc2 …cant you help me …

  79. @Patrick.

    Are these two machines in network. How you want to move data from one machine to another machines, what is the role of VB.NET in this process.

    Can you please provide more details.

    Help us help you by providing more details.

    ~Peace.

  80. I am using Asp.net and Sql Server 2005 express edition ,server is automatically hangs up , if i restart the sql service the application is much faster than expecting ,Few days back this problem is occured .My Project is in live iam unable to understand why these problem raised Please help me out of this situation……
    Thanxs in advance…………………..

  81. Size of Tempdb is 14.31 mb and Available size is 4.95mB , my original table size is 544.94Mb and Available is 0.84 mb , what would be the problem, and how to check whether the no of Open Connection and how many no of connections can opened for Sqlserver Express Edition.Help me out of this Situation ….

  82. first of all check the drive where you have placed the tempdb(which i asked you in my original question to check).
    Is the drive have enough space to handle tempdb transactions?
    Also check again the log file of tempdb size. If its very small in size like 10 mb or less you can increase it to 100 or 1000 mb

  83. Hi ashish , Drive has enough memory , as earlier said my
    Size of Tempdb is 14.31 mb and Available size is 4.95mB ,How to increase the size of Tempb , How to make Auto-Growth flag to “true” where can i find that option , as iam new to this field please help out………

  84. right click on tempdb, select properties and go in files.
    you will see the tempdb mdf and ldf details there.
    Select autogrowth and configure the tempdb_log to autoincrement by 10% and unrestricted growth

  85. hi,

    I also have one more Question
    if there were not any item in sql server network configration
    so what are do then ?

    and sql netive client configration settigs like….
    client protocol
    – shared memory
    – Tcp\Ip
    -defult port = 1433
    -Enaaled = yes
    – keep alive = 30000
    -keep alive interval = 1000
    – NamedPipes
    – VIA

  86. Hai… i am using windows 7 home premium 64-bit in acer laptop.
    I have installed oracle 10g express edition and jdk1.3.
    When ever i try to connect to the oracle using java the error i am getting is SqlException.
    I have tried to solve it by changing the target path to 32 bit but nothing worked…. Can anyone find out a solution for this plzzzzzzz……..

  87. Hi, I want to connect to the Report Server from Sharepoint. But when I access the Report Server page, I got this error:

    “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)”.

    The Report Server and the Sharepoint server run in two different machines.

    I’ve tried all the steps mentioned in the article, but still have this error. Does anybody know how to fix this problem? Thanks.

  88. 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)

  89. Hi,
    this anant from Mumbai. Am doing one project in Visual Studio 2008 and for back hand i had choosen SQL server 2005 Management Studio.
    Am unable to connect database through the .net it giving an of ‘sa login failed’
    What to do? please help me out.
    Thank you.
    Regards,
    Anant.

  90. ===================================

    Cannot connect to INFOSIGHT.

    ===================================

    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) (.Net SqlClient Data Provider)

    ——————————
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=2&LinkId=20476

    ——————————
    Error Number: 2
    Severity: 20
    State: 0

    ——————————
    Program Location:

  91. Hi, I have resolved this issue. Try to disable VIA Protocol and then start the SQL Service in SQL Server configuration manager. It starts fine.
    Thanks

  92. Hi All,
    I am facing the same problem, I can connect my remote SQL Server via SSMS, unable to connect through ASP.NET, it gives an error with details…

    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) (.Net SqlClient Data Provider)

    Application is configured with user id ‘sa’ having all rights.

    when try to connect with a new login named ‘test’ it successfully access database but provides error that respective Procedure does not exists in database, this is due to because user ‘test’ is not dbowner, when assigning dbowner role and schema as dbo it again gives error : 40
    specified above.

    I checked all the settings as per specified in this thread.

    Please help ….
    Thanks in Advance.

  93. hello sir,
    When i run asp.net application on IIS6.0, it shows Error 40[SQL Server does not allow remote connections.]
    As per your assignment i gave all options and modifications(
    I enabled tcp/ip in sql2005 configuration and modified sql exceptions in firewall, and i gave option local&remote connections in sql2005 configuration.) But still im getting same problem
    Please help me
    Thank you

  94. Thanks Pinal,

    Here’s what helped me get over this issue thanks to your pointers and those in this thread:

    The SQL Server Configuration Manager already had TCP/IP and Named Pipes enabled on the node: SQL Native Client 10.0 Configuration. Despite this remote machine could not log on to the SQL server.

    But Named Pipes and TCP/IP was disabled on the node: Protocols for MSSQLExpress

    Enabling both on the second node and adding the default port 1433 to the TCP/IP tab helped establish the connection. The service requires a restart.

    My SQL Browser service remains inactive and despite that remote terminals can connect.

    The MS SQL Server Express 2008 was situated on an Windows XP machine and the terminals connecting to it were Vistas Utimate and Windows 7 Home Basic.

    Ruchir

  95. Thanks is Working
    1) CompMgmt.msc
    Services And Application
    Sql Server Network Configuration
    Protocol For Ms Sql Server
    Enable TCP/IP and Restart Engine Services
    But Could u tell me what is the differennce between Conf. Manager TCP/IP and above TCP/IP. Is Both are not Same?

  96. No need to change this settings and all.Beore i faced same problem while Connecting with SQL Server.Finally i got Solution.Now i’m getting output.So Everyone follow this Technique.
    Simply chek your ConnectionString in Web.Config File.
    Like This———–>

  97. Sir, actually on TCP/IP propteties two tab Ptotocol & IP Addres in IP Address tab also to row TCP Dynamic Port and TCP Port which one I shuld set 1433

  98. Dineshkumar

    Hi i’m trying to built a datagridview in .net using c# as frontend and sql server 2008 as backend..in the event of doing it i got a error that “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)” ….
    i tried all the solutions given above pls help me to fix it as early as possible…
    my code as follows

    private void Form1_Load(object sender, EventArgs e)
    {
    // TODO: This line of code loads data into the ‘testDataSet1.Employee’ table. You can move, or remove it, as needed.
    this.employeeTableAdapter.Fill(this.testDataSet1.Employee);
    {
    string strCon = “Data Source=dbServer;Initial Catalog=testDB;Integrated Security=True”;
    string strSQL = “select * from Employee”;

    SqlDataAdapter dataAdapter = new SqlDataAdapter(strSQL, strCon);
    SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);

    // Populate a new data table and bind it to the BindingSource.
    DataTable table = new DataTable();
    table.Locale = System.Globalization.CultureInfo.InvariantCulture;
    dataAdapter.Fill(table);
    dbBindSource.DataSource = table;

    // Resize the DataGridView columns to fit the newly loaded content.
    dbGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
    // you can make it grid readonly.
    dbGridView.ReadOnly = true;
    // finally bind the data to the grid
    dbGridView.DataSource = dbBindSource;
    }

    thanks in advance..:)

  99. Hi,
    i have sql servr 2005 running on server, I connect all the workstation through named Pipes however one HP touchsmart with vista home premium 64bit is not connecting I can not select named pipes in this system. It is automatically goig back to TCP/IP, please help me to resolve this issue. it is more than 2 week i am trying various things.
    Alex

  100. I am having problem to connect SQL server 2005
    The msg is as follows :-
    The request failed or the serivce did not respond in a timely fashion. Consult the event log or other applicable error logs for details…

    Plz give me some Idea about it….

  101. I am having problem to connect SQL server 2005
    The msg is as follows :-
    The request failed or the serivce did not respond in a timely fashion. Consult the event log or other applicable error logs for details…

    Plz give me some Idea about it….

    An error has occurred while establishing a connection to the server. When connecting to SQL Server, 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)

  102. Cannot open database “shiv” requested by the login. The login failed.
    Login failed for user ‘AGGARWAL\shifali aggarwal’.

    Hello.Sir…above is the error which is occurring…
    so what should i do for this???

  103. I have a similar issue. The only difference is I can connect to SQL Server using an ODBC connection. Then about 1/3 of the way through my process I lose the connection. I get the same message as above, but I had already been connected.

  104. Hello Friends..

    I was also getting below given same error,but my case was little bit different from all the error.i had just change the password of my computer,but i did not change it from Sql server configuration,so you can also try this way,and hope it will help you..

    1:- click run and type > services.msc> find out the SQL Server (MSSQLSERVER) > right click on it, Prosperity >Lon on,then enter the new password of your PC,repeat the same step for SQL server agent..
    after that start the services,i will work fine..

    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. )

  105. 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: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)
    plzz help me

  106. Hi, In my environment we using the tally shoper9 with SQL 2005.and having the same problem of Error 40 : Could not open/establish the connection to SQL server. Kindly help for this problem.

  107. Hi,
    I have installed the SQL Server R2 successfully Serve successfully but it couldn’ connect due to 623XB-MIA-SQL can’t intialize. SO what can I have to do ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s