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://darkslategrey-bat-805937.hostingersite.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

  • Mirwais Ahamdzai
    March 23, 2011 3:21 pm

    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)

    Reply
  • parvaiz abidi
    April 1, 2011 12:25 pm

    Thank you Sir,

    This post solve my problem….

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

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

    Reply
    • Imran Mohammed
      June 1, 2011 8:50 am

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

      Please provide more details.

      ~ IM.

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

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

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

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

    Reply
  • avadeshvadesh
    July 11, 2011 12:48 pm

    Hi Dave!!

    Many thanks for your valuable article.

    It has fixed my problem and made my life easier..

    Keep the good work going……

    Avadesh

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

    Reply
  • nithinnarayana
    July 26, 2011 2:34 pm

    Great Help Pinal.. i am hanging on to find a solution for two days..you saved me..
    lots of thanks

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

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

    Server name = servername,portname

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

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

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

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

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

    Reply
  • don’t you also need to enable named pipes?

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

    Reply

Leave a Reply