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

If you are receiving the following error related to connection to SQL Server, this blog is for you.

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 in 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 cannot be connected from a remote system, in that case firewall on the server where SQL Server is installed can be issued.

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

Follow instructions of this article to fix the issue.

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

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

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

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

Now try to connect to SQL Server again. It will allow you to connect to the server successfully. Please leave a comment with your experience.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Database, SQL Error Messages, SQL Server Security
Previous Post
SQLAuthority News – Security Update for SQL Server 2000 Service Pack 4 and MSDE 2000
Next Post
SQLAuthority News – SQL Server 2008 Downloads Availables

Related Posts

141 Comments. Leave new

  • My Client is on Win Server 2003 and Server on Wix XP 3. I thought that might be helpful to you in helping me.

    Reply
  • Mahmoud el Shaikh
    May 8, 2009 1:26 am

    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

    Reply
  • 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)

    ——————————

    Reply
  • i also tried solution ( add port ) but still give me same error.

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

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

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

    Reply
  • 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

    Reply
  • need to enable netbios then it worked.

    Reply
  • And where can i do that?

    Reply
  • @mac

    I found it, did it but i still have the problem.
    Maybe i did something wrong with installation??

    Reply
  • 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

    Reply
  • 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…

    Reply
  • 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!

    Reply
  • 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 …………

    Reply
  • Thanks a lot. Start SQL Browser resolved the issue.

    Reply
  • 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!!!

    Reply
  • mssqlserver should started fist, it will solve the problem

    Reply
  • 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

    Reply
  • 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

    Reply
    • 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-)

      Reply

Leave a Reply