SQL SERVER – Fix : Error : 1326 Cannot connect to Database Server Error: 40 – Could not open a connection to SQL Server

If you are receiving following error:

TITLE: Connect to Server
——————————
Cannot connect to Database Server.
——————————
ADDITIONAL INFORMATION:
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: 1326)

I suggest that you read previous article first as that describes how to fix the problem and has worked for many cases.

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

Now if SQL Server can be connected perfectly from local system but can not be connected from remote system, in that case firewall of the server where SQL Server is installed can be issue.

Follow instructions of this article to fix the issue.

Go to control panel >> Firewall Settings >> Add SQL Server’s Port to Exception List.

Now try to connect to SQL Server again. It will allow you to connect to server successfully.

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

About these ads

135 thoughts on “SQL SERVER – Fix : Error : 1326 Cannot connect to Database Server Error: 40 – Could not open a connection to SQL Server

  1. Hello,

    Just to add 2 cents to your notes,

    I came across same problem last week, and I came to know that we have to do the following things in order to solve the above issue,

    1. Disable windows firewall, or make an exception and add port number for SQL, this works well if you have only one instance of SQL Server, if you have more than one SQL Server instance then I guess you have to enable all other ports used by SQL Server.

    2. In “Client Network Utility” tool of SQL Server add the server name of ip address of the server you are trying to register in the Alias section and most important choose which type of protocol you want to choose, either named pipes or TCP/IP

    3. If you are using 2005, then use SAC to enable, allow remote connections to server and to use both TCP/IP and named pipes to connect.

    Please correct me if I am wrong.

    Thanks,
    Imran.

    • I’ve chenged the TCP/IP address of the SQL protocols and now i can’t remember it can you please help me how to recover it i get no connectivity error

  2. There are couple of to troubleshoot this problem. The one you should use depends on how your databse server was configured.

    For example, if you configure the database engine to use dynamic port allocation, make sure that sql browser is runnning.
    SQL browser provides the connection information about the database engine to the the client.

    If the sql browser is not running and you have restarted sql server and port 1433 is being used by other applications,
    database engine will be allocated a different port number. Imagine that the client has been configured to use port 1433
    to connect and the database engine is using a different port number. The client wont be get the connections properties to the database engine from sql browser
    because sql browser is not running.

    To avoid this type of problems, when the database engine has been configured to use dynamic ports, make sure that your sql browser
    is always running.

  3. Sorry–
    There are couple of ways to troubleshoot this problem. The one you should use depends on how your databse server was configured and some other factors as well.

    For example, if you configure the database engine to use dynamic port allocation, make sure that sql browser is runnning.
    SQL browser provides the connection information about the database engine to the the client.

    If the sql browser is not running and you have restarted sql server and port 1433 is being used by other applications,
    database engine will be allocated a different port number. Imagine that the client has been configured to use port 1433
    to connect and the database engine is using a different port number. The client wont be get the connections properties to the database engine from sql browser
    because sql browser is not running.

    To avoid this type of problems, when the database engine has been configured to use dynamic ports, make sure that your sql browser
    is always running.

  4. I swear, I have absolutely exhausted every concievable solution to this problem, and I’m still stuck.

    I’m getting this error in CRM 4.0 when embedding an ASP page with a gridview of information from a stored procedure on my database.

    I’m pretty sure it’s Kerberos related, because the page connects fine on my development workstation, but fails on the CRM web server (where there’s a double-hop between my credentials and the SQL server) It’s been broken for weeks now. Here is a (partial) list of the fixes that have NOT worked:

    Surface Area configuration: Both Named Pipes and TCP/IP enabled.

    SQL Server Browser is running

    Added the server name, and the server\instance into my HOSTS file on the server.

    Changed my connection string to the IP address, just the hostname, and the hostname\instance name

    Added SPNs for every possible permutation of: hostname, host\instance and IP address.

    Confirmed that both the NT AUTHORITY\NETWORK SERVICE and HOSTNAME$ accounts have connect rights to the database.

    The final weirdness: I wrote another page and put it into another web application on the same web server. It DOESN’T have the error, but it doesn’t work either. The gridview just comes through as an empty tag. Other ASP controls, like labels and buttons, work fine.

    At this point, I will give either pinky to get this working.

  5. Forgot: the windows firewall is disabled, and besides, the app works when running in the ASP development server of VS 2005 n my workstation, and of course, all of CRM works (although it mostly uses web services).

  6. I’m getting this same error message ONLY when I specify the IP address as the server name. Everybody else in the office can hit the SQL Server — using the IP address — on my partner’s PC except me! And I can connect if I use the machine name instead of the IP address.

    This just started this week, after I installed SQL Server 2008 on MY machine — my partner’s box, the one I’m trying to connect to, is still 2005. It worked fine with EITHER machine name or IP address before that.

    It’s not a firewall issue, since everybody else can connect to his server using machine name _OR_ IP address. I can only connect using machine name.

    It’s not a protocols issue on his server, because — again — everybody else can connect to him except me. And I ONLY get that error message if I specify the IP address instead of the machine name.

    And yes, the IP address is correct. :)

    Anyone have a clue?

  7. provider: Named Pipes Provider, error: 40 – Could not open a I was getting this error:
    connection to SQL Server) (Microsoft SQL Server, Error: 1326)

    I changed the protocol from Named Pipe to TCP /IP and it worked. Thanks.

  8. I was getting this error:

    provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 1326)

    I changed the protocol from Named Pipe to TCP /IP and it worked. Thanks.

  9. Dear sir, i have read your threads for following error :
    “An error has occured whil establishing a connection to the server. When connecting to SQL Server 2005, this failure may be casued by the fact that under the default settings dose not allow remote connection.(Provider : Named Pipes Provider, error:40-Could not open a connection to SQL Server)(Microsoft SQL Server Error : 5)”

    so please send me possible solutions which i can try.

    regards,
    ritesh

  10. Dear sir,
    i agreed with Ritesh… i m facing same problem, so please send me solutions.

    i have read your threads for following error :
    “An error has occured whil establishing a connection to the server. When connecting to SQL Server 2005, this failure may be casued by the fact that under the default settings dose not allow remote connection.(Provider : Named Pipes Provider, error:40-Could not open a connection to SQL Server)(Microsoft SQL Server Error : 5)”
    so please send me possible solutions which i can try.
    regards,
    yatin

  11. Pingback: SQL SERVER - Fix : Error : 40 - could not open a connection to SQL server. Journey to SQL Authority with Pinal Dave

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

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

  14. I’ve a named instance (say, INST1) with the port changed to 1432

    Under “Connection to server”

    SERVERNAME,1432 ==> Every client works fine

    SERVERNAME\INST1 ==> Some machines cannot make connection with this server name (seems cannot resolve the port no.)

    It makes me confuse since not all clients cannot make connection with SERVERNAME\INST1

  15. Hello Sir,

    I am facing one small problem in one of my dummy SQL setup that I have prepared for TPC-E benchmark.This is just to have testrun before I go ahead with the actual test with real setup.

    Just to give a brief : I have different Database server and Client server .Setup is prepared as mentioned below.Now I am trying to use SNAC tool to establish connectivity between the two .But MDAC is working fine.My trouble epicenter is Server-Client Connectivity using SNAC tool.

    I have a separate Server installed with SQL Server 2008 , service also started , created one database through TPC-E scripts, installed SNAC tool.

    I hv separate Client machine on same network ( both can reach each other over TCP/IP) , installed SNAC tool.

    Now I am getting an error: “Message:[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ” , whenever I start some TPC-E scripts on Client machine to start work on Database server.

    In the process I tried some DSN configuration as described here http://www.mssqltips.com/tip.asp?tip=1471 . I tried to define it on both Server and Client .But this is not working.

    Have also tried with Aliases creation .Referring to http://www.mssqltips.com/tip.asp?tip=1620.

    What settings to be made on both Server side and Client side to overcome this issue. Any extra components I need install on Client side or Server side.

    One more thing I hv observed is that SNAC version on both Client and server are different , can this be a problem. Is it required to be same.

    Any relevant inputs on this will be helpful.

    At the end I should tell you that I am pretty new to this SQL server domain , so my level of struggle has been quite at a higher scale all through the project run.Hope this will over soon.

    Thanks & Regards,
    Sudipt.

  16. After all the steps mentioined above, you might still not be able to connect for SQL2005 Express.

    One of the trick for SQL2005 express is that when you connect the server, you can’t just type the server name but have to type “servername\EXPRESS” instead. This applies to both SQL Server Management Studio and the code.

    • Errors:

      An error while executing your request.
      A network related or instance-specific error occurred while stabling 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: name pipes provider, error: 40 could not open a connection to sql server.

      error: Msg 17, level 16, state 1 [Microsoft][ODBC SQL Server Driver][DBNETLIB] SQL Server does not exit on access denied how to solve

  17. Dear sir,

    I got this error while configuring transactional replication between two different SQL Server 2008.

    I have two SQL 2008 Servers, connected via internet such as A and B.

    I configure Publisher on Server A and try to add the subscriber the server B, but unable to connect the server B

    error as “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) (.Net SqlClient Data Provider)”

    When I use the Management studio of Server A to connect the server B the connectivity is done successfully,

    But while adding subscriber it does not work..

    Please help me in this regards.

  18. Hi,
    I’ve installed SQL Server 2005 and ‘Query Express’ to access it on the same PC. When I’m getting this connection failure error 40 message & I’ve applied all the advise given on above but nothing seems working. I feel exhausted now. Please adivse.
    Many Thanks.

  19. Hi All
    I have a SQL Server 2000 running on Win2k3.
    I am trying connecting to SQL locally on the Enterprise Manager on the machine but
    I get this error: “A Connection could not be established to local
    Reason: Encryption not supported in sql server
    Connectionopne (prelogin(handshake)).”

    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

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

  21. hii,

    I try to connect to my database sql server 2005 from a jcreator app usind odbc… The main problem is that I can not configure the odbc data sources to connects using neither named pipes nor tcp/ip please help

  22. I am getting this kind of error. can you please help me solve this problem . when i was installing SQl sever at that time i didnt give any login name and password . so i dont know what to give in login name and password. and also have problem with connecting SQL sever
    please help me out

    TITLE: Connect to Server
    ——————————

    Cannot connect to 76.194.236.194 .

    ——————————
    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: 3)

    ——————————

  23. Hi,

    (.net 2005 C# Windows Application)

    My Connection String is :

    string ConnString = “Data Source =//./pipe/MSSQL$SQLEXPRESS/sql/query;Initial Catalog=ErollNewDotNet;uid=sa;pwd=sa;”;

    I got error like this at this point :

    SqlConnection SqlCnObj = new SqlConnection(ConnString);
    –> SqlCnObj.Open();

    The error 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 have checked :
    –Sql server service is running,
    –Named Pipe and TCP/IP both are enabled;
    –Firewall is Off and Remote connection is also enabled .

    And the most socking thing is same connection string is running successfully in my other web application project.

    Y this Error ? Please Help me asap.
    Thanks in Advance.

    Latu.

  24. Hi!

    I’ve had a problem and solved it!

    On remote machine in “SERVER NAME”, I’ve entered a name in format “%computername%\SQLEXPRESS” and everything worked just fine.

  25. I have problem in SQL2000 Server. Here is what i got an error while connecting remotely.

    —————————

    SQL Query Analyzer

    —————————

    Unable to connect to server 10.0.0.153\sql2k:

    Server: Msg 17, Level 16, State 1

    [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.

    —————————

    OK

    —————————

    Instance name is correct i could able to connect locally. But couldn’t able to connect remotely.

    Firewall is off in my server and even i checked Default port of TCP\IP protocol properties. Earlier it was 0 after that i configured with 1433. But problem is Remain same.

  26. Hi all, i have a question.
    First i don’t have any experience with sql.
    Now.
    I want to make a private server for a game named Kal online.
    After much researching i found a guide that said to install SQL.
    Now i have downloaded SQL 2000 and i installed it on vista.
    Many people say it can’t but he installed it so i want to give it a try.
    After the installation i open the server but i get this massage:

    Acces denied

    and then An error 5 occuredwhile peformingthis service operation on the MSSQL service.

    I have searched and searched but i can’t seem to find a solution!!

    I hav tried all the above but it doesn’t help.

    I really hope someone can help me with this problem!!

    greetings nick

  27. hello
    it my problem in the sql server2005 is connected ..
    so then and sever name is not show …
    can you tell me how is connect the sql server 2005 …
    pls tell

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

    pls tell me
    i dont understand i waiting your reply…

  29. 1. Allow remote connections… CHECK
    2. Firewall open… CHECK
    3. Instance is on port 1433… CHECK
    4. SQL Browser is not running… CHECK

    I would get this error when using the IP address as the Data Source. Also when using IP,1433. However, when I switched to a DNS name that resolves to the same IP address, the error went away. Go figure!

  30. @Lex3001

    3. Instance is on port 1433… CHECK

    You can have any port number for SQL Server. By Default SQL Server will be using port 1433, it does not mean that you/sql server cannot use any other port. This should not be an issue.

    I would add one more check to your check list, as
    Step 0. First, Check if SQL Server Service for that particular Instance is running or not— CHECK

    When SQL Server to which you are connecting is a Default Instance then you can use IP Address as your data source

    SQL Server : Default instance
    IP Address to connect : ip address of host machine.

    Ex :
    SQL Server : Default instance
    ip address of host machine : 192.168.1.100

    Then you will use the same ip address.

    When connecting to Named instance of SQL Server, then you will use

    SQL Server : ComputerName\InstanceName
    IP Address to connect : ip address of host machine\InstanceName

    Ex:
    SQL Server : IMRAN\PROD
    Ip Address of host machine : 192.168.1.100
    IP Address to connect : 192.168.1.100\PROD

    One more important reason why this could fail,
    Check your Port No: Its need not be always 1433,

    Use this script to find out port no of sql server instance.

    http://www.sqlservercentral.com/scripts/Miscellaneous/67422/

    ~ IM.

  31. Hello Sir, i have one asp.net applcation which is running on my LAN …..
    Some time i got this kind of error when i start my application “The connection was not closed. The connection’s current state is open.”
    and
    i also got this kind of error ” Timeout expired”
    plz try to sloved my error …………

  32. Verrry helpful.

    Our admin spent a day to try to resolve this issue.
    I got this help, teach him and got the credit as Smart(test)… kidding. Anyway thanks a lot for the site!

    Really helpful!!!

  33. I have problem in Connecting remotely to SQL2000 Server.

    In Local Network every thing is OK and connection is established correctly.

    But when i try to connect to server (having real IP), the following error occurs

    [DBNETLIB]SQL Server does not exist or access denied.

    Firewall setting is done as mentioned.
    TCP/IP port properties is done as mentioned.

    But problem is Remain same.

    I need help.
    Thenks

  34. I get the same error message, but in a different setting:

    client: Win7 with SSMS 2008

    server: SQL2005

    The problem only occurs with 1 of the SQL servers here, and only with some clients.
    The client specifically indicates to use ‘SQL Server Authentication’, and user ‘sa’ with the correct password.

    However, when I check the event log on that server, it appears that the client tries to authenticate with Windows Authentication instead! (Which does not work, since the client and the server are not in the same domain)

    Why does it use Windows Authentication when SQL Server Authentication is specified?

    Evert

    • Turned out that in our case the SQL-server was NOT listening on its standard port, but had been configured to listen on a different port instead… 8-)

  35. Si,
    I have a problem. I have one server 2003and 100 client xp.
    server is in workgroup bt client are in all domain.
    client can not access server where xp are in domain.
    client can not access sql server.
    i set odbc in client. bt got an error:
    connection failed sqlstate ‘HYT00′, SQL SERVER ERROR :0

    plz help me

  36. Msg 28102, Level 16, State 1, Line 2

    Getting this message when i execute any Query in New Query Window, and keep on showing ‘Debugging query’ message in status bar of SQL query execution window

  37. Hello Amar,

    It seems you are working in SQL server 2008 and instead of executing you are debugging the query. Click on Execute button or press F5. Instead of debug |> button.

    Regards,
    Pinal Dave

  38. 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: 1327

    I am Getting this problem again and again plz zzzzzzzzzzzzzzzz solve my prblm

  39. I upgraded to SQL Srvr Express 2008 and now I can’t access SQL Srvr 2000, or any of the databases. These are all on my local machine. I didn’t detach any of the 2000 databases, and I can’t attach to them using 2008. How can I get 2008 to work with the 2000 databases?

    I had SQL Srvr 2005 n this machine also, it ran in harmony with SQl Srvr 2000. I have already spent a couple of days making changes to files to work with 2008, but I must also work with these older applications.

    If I try starting the instance of SQL Srvr 2000, it tells me it can’t find the default instance of SQL Srvr.

    Any help will be appreciated.

  40. I set up an exception on the firewall, but the firewall is off anyway. This had no effect. I can’t attach to the 2000 databases from 2008, it won’t even let me expand the directories where those files are located. I can’t access them through ASP pages. I can see the database files and copy them with Windows Explorer, but SQL Server 2008 will not use them.

    This computer is running Win XP, SP3 and also has Sony Acid on it, which uses a SQL Server 2000 database and I have set for Manual Startup. That appears to be working. But the instance of SQL Srvr 2000 installed years ago for development is dead. And I need to access the data in those databases to maintain older applications.

    Any other suggestions? I just need the data, I can use 2008 if I can just attach to the databases.

  41. @Jim,

    I am sorry but I am having hard time understanding your question, you said you are not able to connect to SQL Server 2000 database after you upgraded it.

    1. Can you please provide error message what shows up on your screen why you try to connect to SQL Server 2000 database.

    2. Also what is the size of SQL Server 2000 database, because you are using SQL Server 2008 Express edition, it has a limitation that database size can only be less than or equal to 4 GB.

    Stop SQL Server 2008 instance. Copy SQL Server 2000 database files (data files and log files) and move it to a new location. Start SQL Server 2008 instance and then try to attach database files following regular attach database process.

    ~ IM.

  42. Thanks for the reply. There was no error message, the browser just sat there with the message “Connecting” – but it would never connect. The largest database was about 350 meg.

    I could not get it to work after trying all suggestions I could find and I can’t make any money unless I can actually test what I am doing. So I started detaching the databases from other computers to reinstall on my current work machine (the data is old, but at least we can work on the apps). This morning I drove a hundred miles to get copies of the two which need changes to associated web pages. Over the last couple of years, the data files had been modified too much to try to use older versions of the databases. I attached the new copies this evening, now I am just modifying connection strings.

    One other note, before I could attach the databases I had to modify the security on the directory for my ID. Even though I have admin rights, I had to give myself create rights to attach the databases.

    I am back in business, but it just burns me up that half the time when M$ pushes out a new release we have problems that take hours (sometimes days) to resolve. And many of the issues (like this one) take a while to discover because we are not working on every application every day. I wish I had taken up something simple like brain surgery, this upgrade/update nightmare never ends. Browsers, SQL Server, Visual Studio, the operating system, firewalls, etc,. etc., etc. No upgrades on brains – they either work or they don’t (seems like more don’t than do).

  43. hi!
    i can’t register sql servers that haves only TCP/IP protocol in server network utility and raised exception “SQL Server dose not exist or access denied”

    Regards,
    saval

  44. Hi Pinal,

    i need to know that i am having SQL Server 2005 in my local PC . now i need to connect to server ie SQL Server 2008 . but i have full permission for both. if connected i can’t able to create a database.(Error: could not create a database acces denied,do’t have permission to create a database)

    can u help u out from this.

    Thanks
    ravi

  45. Hi, Dave-
    I am learning SQL Server 2008. I have installed the complete package on my local PC. I can log on no problem using my default ‘windows authentication’.

    Following a study guide on how to create a new user and password I did the following:

    USE master
    GO

    CREATE LOGIN Murray
    WITH PASSWORD = ‘ABC$$123′

    it seems it processed this successfully, however, when trying to log in, after selecting ‘SQL Server Authentication’, I get the following error dialog:

    TITLE: Connect to Server
    ——————————

    Cannot connect to .\Master.

    ——————————
    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: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)

    Now, while logged on under ‘Windows Authentication’, I right clicked on the server and went into properties, Security, there I selected the radio choice for ‘SQL Server and Windows Authentication mode’. I closed out and restarted but Murray password will NOT work at all.

    I even used the following command:

    USE Master
    GO
    GRANT CONTROL SERVER TO Murray

    But that did not help either…

    I will appreciate any help.

    Regards

  46. I have a real difficult twist on these cases:

    I have SQL Server 2008 running on Windows XP Professional

    Windows Firewall is OFF

    SQL Server Services: SQL Server, SQL Server Browser, SQL Agent are all running.

    Protocols: Named Pipes, Shared Memory and TCP/IP are enabled

    SQL Server Enterprise Manager running on the same machine cannot see the local SQL Server instance.

    The database is set to Windows Authentication – this instance has until today worked without fail.

  47. Can you please help me out with this problem

    i have installed sql server 2005 now iam not able to connect to the server what could be the problem and can you say me what is the server name should i give and what type of authentication should i give for this type. My system is a local system connected with net connection and i have added port in the firewall settings.

    Can you help me out with this problem please mail to [email modified] as soon as possible.

  48. hello

    i have sql server 2008 and when i try to log onto my terminal command interpreter,i get the following error message”No port information found for host………..(which is the computer name)”

    my sql database is not running

  49. I solved my problem. I uninstalled the SQL Server 2008 piece of crap and reinstalled SQL Server 2005. IT WORKS FINE. It is ridiculous that a Microsoft product will not install on a Microsoft operating system without spending hours on blogs and trying useless attempts to make it work.

    Maybe I will try again in a year or two, but at least now I can use my laptop for work.

    The irony is that 2008 installed fine on my XP machine (the OS M$ wants to retire) but won’t on my Win7 OS (the next generation???).

  50. Thanks For Above Setting I done it
    But Currently problem is occurring that Every one on network can access my sql server but i can’t access other servers so if there any clues to setting then please reply

    I am using SQL server 2008 and microsoft server 2008

    Thanks…

  51. Hi,

    This is really great help me to solve the problem when This error occur.

    But I have One More problems that
    Other Network SQL server can access me but i cannot access their server AND I have been Set all the settings that are given above.

    So Please Help me out for this problem

    Thanks You.
    Amit Tank

  52. Hi,

    i was getting an error which i successfully resolved :)

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

    changing the server name from (local) to “localhost\\SQLEXPRESS” and it worked!

    This solved my problem ..:)

    Regards,
    Syed Mujtaba Ahmed Razvi

  53. This was exactly what I needed..

    I had a new server installed in Deutsch and even though I can speak enough Deutsch day-to-day, I couldn’t get my way through all the interfaces to find the correct firewall setting without going slightly crazy.

    These pictures helped me muddle my way through and now I can connect remotely to me new server :-)

    Thanks Dave, as always a wealth of knowledge and one of the best SQL resources out there.

    Cheers, Aaron.

  54. Hi sir,

    I have come across your blog and it is very informative. Currently, i have a very serious issue with SQL server connectivity.

    I get the following error when i try to connect to SQL server from a client location ” A network related or instance specific error occured 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 conenctions.( provider: Named Pipes Provider, error: 40 – could not open a connection to SQL server. )(Microsoft SQL server error : 53)

    I tried connecting to the server from another client machine and it works fine. But, from my machine i am not even able to ping the server. Firewall is disabled, TCP/IP enabled, SQL services are running fine.
    However, I am able to ping other sites.

    Do you think it is a Network firewall issue?

    Please please help me out with a solution.

    • hi niharika….

      this is sridhar

      go to windows firewall settings and press exceptions tab

      and go for add port give the following details …

      name : sql

      port no: 1433

      and select ” TCP ” radio button …..

  55. Dear all,

    I have a big problem, pls give me solution.

    I ‘ve an app. In this app, client (C# win form) access to sql database thru web services (C#). If i deploy web services and Database on one server, it work ok. But if i deploy on 2 server (in LAN), it not work, the client fire exception 1326. The Data server with: OS Win Server 2003, SQL 2000.

    When I use SQL Server Management Studio (on Services Server) to connect to Data Server this connected. I’m enabled TCP/IP and Named Pipe too, Firewall is Turn off.

    Help me pls.
    tring chuong

  56. I have a problem with ODBC, and SQL connectivity. Let try to explain.

    The SQL server runs on our DATA BASE SERVER with and OS Windows Server 2003.

    The ODBC CLIENT runs on our Application Server OS Windows Server 2008 64 bit.

    After configuration of ODBC and pointing the connection to the DATABASE required. The ODBC returns an error 10016 and further indicates that it is unable to connect to the TCP socket.

    We have configured the TCP/IP port and added the exception to the fire wall as per this sites instruction but still no luck.

    We noted that 10016 seems to suggest registration errors, we are reluctant to run the reg edit as these are all fresh installations. Also the down load program for reg edit only supports the 2003 and not the 2008.

    is it possible that we have compatibility issues with the different OS

    or should we be looking else where
    Can anyone help in this regard

  57. I have same error message but the scenario is different.I have a xp machine with sql server 2000.When i connect that db from my client xp machine sql server 2005 it connects but when i try to connect from windows server 2008 with sql server 2005 it give me error message as shown above in article.

  58. Iam getting the error.
    Login failed for user””error 18546
    as i try to connect to sqlserver 2005 on a sever

    Pliz help

  59. I never did get around this problem. But I found I could get the Developer Version of SS 2008 from M$ for only $60, so I ordered it and installed it on my computer. I got all kinds of errors saying it was not compatible with Win XT, but I ignored them and it installed okay. Now I have SQL Server and I can also do BIDS, SSIS, SSRS and have all the functionality SQL Server has. It was so much better than the free versions of SS and the features of that version allowed me to learn enough to land a new contract which will carry me for a few years.

  60. Here’s a definite way to solve this problem.
    Open SQL Server 2008
    At Server name select ‘browse for more’
    Go to Network Servers and select the listed server(which would be like [URPCNAME]/[INSTANCENAME]).
    Connect using Windows Authentication mode and u are done!

  61. Hello Pinal,
    I need your help.
    i have made one application in C#.net 2008,basically application work for Server-Client architecture (LAN Network).
    i made the setup of my application and its connecting perfectly fine on server where sql server express 08 install.i have install my application on client machine also and then after when ever running the application from client machine its refused to connect with sql server express its throws my coding generate message like “Unable to establish your connection to data source.Configure your setting and restart your application”
    when i start the application at that i have configure like that its ask to enter the sql server name then its generate the connection string and connect it.
    i am using standard connection string…
    “Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;”

    Can you help me in that what kind of problem is that.Can you assist me please.
    waiting for your reply

  62. hi thanks in advance…..

    i am installing visual studio 2008 in my system and the database is sql server 2005 management studio express edition , when i am trying to connect sql server 2005 management studio express edition it gives following error….

    please help me anybody….

    the error is : Connect to 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) (.Net SqlClient Data Provider)

  63. Hi all,

    Non of above solutions worked for me :(

    Error message –

    Server is not available. Check Web.Config and database configuration.
    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 my connection string syntax -

    1. I am using SQL Server 2005, Studio Express (free edition) on Windows Server 2003 SP2
    2. SQL server is running on the same box as the IIS server
    3. Added exceptions on the firewall
    4. Made sure that SQL Server and Server Browser are running on services
    5. TCP/IP in enabled under SQL Server Configuration

    Jenish

  64. Hi all,

    I have installed Navision in 2008 server with SQL2005. While opening a database from client side I am getting an error message like

    Error:[Microsoft][ODBC SQL Server Driver] Timeout expired State ID: HYT00

    But if I include the user in local Administrator group then I am able to open the database without any error message.

    Note: The clients are not under domain

    Anybody can help me out to solve this issue.

    Sridhar

  65. Hello,

    I have two servers A and B. I want to connect server B from server A and create a new database. This has to be done using stored procedure.

    Please give me reply ASAP.

    Thanks

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

  67. Here’s a definite way to solve this problem.
    Open SQL Server 2008
    At Server name select ‘browse for more’
    Go to Network Servers and select the listed server(which would be like [URPCNAME]/[INSTANCENAME]).
    Connect using Windows Authentication mode and u are done!

  68. i am trying to host my website to IIS server. the website is working fine on local server. but after hosting, it couldn’t connect to database.
    what should i do?
    thanks

    • What kind of Authentication are you using in your connection string and in your IIS for that published Weblink ?

      Please provide more details.

      ~ IM.

  69. Hello sir,
    I try all the option above.
    but i can not solve error 40.
    please reply as early as possible.
    what is basic reason for this error?

  70. Hi Can anyone help me about this issue
    “A connection cannot be made. Ensure that the server is running.The cube must be queried for you to browse data or meta data”
    This is an error while I try to connect cube from visual studio 2008 to database engine (SQL server 2008 R2 developers edition)

  71. Hi

    I am having an issue connecting to SQL Server 2003 from access applciation 2003 both on the local machine. I am able to test the ODBC connection using the ODBC datbase source adminitrator and test shows as successful. But when I try connectign to through Access I get the following error.

    SQLState: 01000

    SQL Server Error 1326

    [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect())

    Connection Failed:

    SQLState 08001

    SQL Server Error: 17

    [Microsoft][ODBC SQL Server Driver][DBNETLIB] SQL Server does not exist or access denied.

    Please help

  72. Greetings,

    This article helped me solve a connection problem to SQL Server 2005 installed on Windows Server 2008 R2

    I added the sql service executable SQLSERVR.EXE located in the SQL Server folder to the firewall exception list and it worked just fine.

    Thanks for the help

  73. haii all,

    i have problem with window server 2003 sp2…my client window XP sp3 cannot connet to server ( fail to connect to sql server )…but i try install client at XP sp2…it’s work!!…and also window7…all working fine..please help me to solve this problem urgently

  74. Thanks to SL.Kwok.
    I was searching for the right string format to give in ‘Server name’.

    , worked for me.

    Who would expect to give a ‘comma’ instead of a ‘colon’

  75. Please see that the string did’nt come up properly when I used less than and greater than symbols…

    Server name = servername,portname

  76. I am working on a windows 7 platform(ultimate x64), I’m using a certain framework in my development called adelphi using sql server 2005. when I run the framework I get this error
    ‘databasename’ could not connect to the database server ‘computername’ on port 6000, socket error 10061, connection refused.

    please help me
    thanks

  77. hi
    how to connect sql2008 databtse to j2ee using driver two code??
    we use the following code..

    Connection con;
    PreparedStatement ps;

    Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
    con=DriverManager.getConnection(“Jdbc:Odbc:Hospital”,”sa”,”pass@123″);

    At the time of running we get tje following error..

    “Errorjava.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid string or buffer length”

    plz help me……

  78. Hi Everybody,
    I am facing one issue, Description is as follow:
    My SQL database server is running in Domain A
    And I am installing my application client in Domain B,
    when I am putting my database instance name, and IP during installation of my client application it is “Unable to connect to database server, please check that database server is valid before proceeding”

    But with the same detail I am able to install my client application in Domain A without any problem.

    Help me to resolve this problem.

    Thanks in Advance

  79. DUDE ITS WORKING NOW ………….
    I am using Windows 7 Home Basic Addition on my server
    and have been installed MSSQL server 2000 with its latest Service pack
    I was in trouble to connect sql server database through my clients, after reading your instruction given above, i have added a SQL port from my Windoes Firwall > Advance Setting > Inbound Rules > New Rule > Port > (Specific Local Port) 1433 > Allow The Connection > Finish

    Its Great Yaar ..
    Thanks Again
    Lahore

  80. I have absolutely no problem connecting to my SQL 2008 database remotely when using RazorSQL. However, I have never been able to connect successfully when I try connecting via SQL Server Management Studio.

  81. Sir, all Installation process of VisualStudio2008 is complete but can’t install sqlserver2005. Now how can install it in my pc? Pleeeeeeeease help me.

  82. I had the same problem on my remote worked perfectly but not locally, then when I wanted it to work you move around and move it badly an option in “Client Network Utility” when he was in that tab or window I select “Force Protocol Ciphers” just remove it and that you will return to normal at least so I resolved my problem …

    I hope they serve
    thanks
    Greetings from Mexico.

  83. Hi,
    Could you please tell me what is the meaning of ‘Property login was not set’ in sql server 2008 R2? because of this I am unable to connect with Database Engine, Analyst services & reporting services ?

    Thanks
    Neela

  84. I installed SQL 2012 Express onto a VMWare VM running Windows Server 2008R2. I had no problem connecting locally on the VM. However, I was unable to connect to it from a remote machine until I overrode the server’s default Windows Advanced Firewall Public Profile for Incoming Connections of Blocked to Allow. Adding incoming connections for port 1433 did not seem to work. FWIW.

    • I am actually having the same problem now, SQL 2012 express running in WServer 2008R2, but trying to connect from an application running in a windows 7 pc. Did you solve the connection issue?

  85. Hi i am getting the problem sometimes it open the sqlserver without any problem but some times it gives the error:-
    cannot connect to smarty-pc
    A network related or instance specific error occured while establishing the connection to sql server server is not found or accessible.verify that istance name is correct and sql server is configure to allow remote connection.(provider:named pipe provider,Error 40-could not open a connection to sqlserver)(Microdoft sqlserver error -2)

    I am already tried:-sql server configuration manager
    where protocol for sqlexpress shared memory,named pipeline,TCP/IP,VIA all are enabled.
    2)Control panel >Firewall>Exception>Remote assistence(checked)>Add port>Then sql comes in exception list with checkbox checked.

    It still give the same problem Tell me how to recover from it????

  86. hello sir! thanks from your nice and outstanding cooperation.
    i read these all information like how to install SQL server but i have some problems the problems i try to connect SQL with database but it did work

  87. PRIOR to put your pc name or server name /sqlexpress when you call your local SqlServer -because sqlserver express 2008 by default names your sql server like that

  88. I have read many posts about this error and still have issue. Here is my configuration.

    Running SQL Server Express Edition 2008
    TCP/IP is enabled
    Using Windows Authentication
    Only 1 instance – CHDC04\SQLEXPRESS
    User name for this PC is listed under “users” on server

    On Client running Windows 7 trying to open a MS Access adp file that has the following connection string:

    This is my VB code that runs on startup of the application:

    BaseCS = “PROVIDER=SQLOLEDB.1;INTEGRATED SECURITY=SSPI;PERSIST SECURITY INFO=FALSE;INITIAL CATALOG=LeadTrack;DATA SOURCE=CHDC04\SQLEXPRESS;Use Procedure for Prepare=1;Auto Translate=True”

    CurrentProject.OpenConnection BaseCS

    Try to run application and get
    “Sql Server does not exist or access is denied”

    I have tried adding port 1433 to the connection string too, but that has not helped. Please point me in the right direction.

  89. Can you help me? i have problem in my Sql server 2008 that i cant to connect my server name,, because its deleted..
    i wanna its back. and i wanna use it again.
    can you explain a solution?

  90. Hello. I’m on a Windows 7 – 64 bit OS. I have Norton 360 installed (that takes over Windows Firewall settings). I’ve re-installed SQL Server Management program 5 times (and rebooted after every removal and reinstallation).. but I cannot connect. I don’t even see a SQL Service created. Any ideas?

  91. We have a MS SQL DB server for Cricket DB .
    The requirement is to Enable a Oracle Subscription for a sql server Publisher on our cricket DB, so that we can send live updates in real time.

    I am facing an issue while configuring the subscription.
    This is what I have tried:
    1. Configured a sql server publication with articles
    2. Tried to configure an Oracle subscriber to publication configured in step 1 but seems like the Data source Name is not being recognized by the sql server.
    It does say the subscription is configured but it gives error while initializing the snapshot.
    Any idea on what could be going wrong here?

    Also, one issue here is, I think it looks for TNSNAMES.ORA file for the data source name that I provide. I have sql developer as the oracle client and I don’t connect using the TNS name.
    In this case where do I need to place the TNSNAMES.ora file?

    Any thoughts on this would be appreciated.
    Also if you are aware of any alternate way to approach this it would be helpful. Please advise.

  92. Hi there.
    I have this error, then I couldn’t connect to only one of my server instance(MSSQLSERVER).
    —————————–
    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)

    http://i50.tinypic.com/2ynpkwy.jpg
    —————————–

    so I couldn’t connect to only one of my server instance (MSSQLSERVER). So I checked the server configuration manager and I see
    SQL server (MSSQLSERVER)
    SQL Server Agent (MSSQLSERVER)
    SQL Full-text Filter(MSSQLSERVER) are not running, even when I start them manually.

    Then I changed the protocols for MSSQLSERVERVIA (status to disabled)
    http://tinypic.com/r/6ir5w6/6

    Then error is resolved.
    I tried in different ways fixing the error and making the error.
    Thanks.

  93. Hi,
    I have 2 copies of SQL Server installed on my local PC, SQL 2008 and SQL 2012.
    When I start ‘SQL Server Management Studio’ for SQL 2012 and I enter (local) as the ‘Server name’ the SQL 2008 engine is loaded/used.
    How can I get the SQL 2012 engine to loaded/to be used when I enter (local)?
    Thanks in advance,
    David

  94. even microsoft can not resolve this….this differs from pc to pc…once pc connects and other not…..both intalled together….. crazy SQL server

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