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: 5)

The video below resolve the error above.

A network-related or instance-specific error occurred while establishing a connection to SQL Server
About these ads

About chanmingman

Ming Man is Microsoft MVP since year 2006. He is a software development manager for a multinational company. With 25 years of experience in the IT field, he has developed system using Clipper, COBOL, VB5, VB6, VB.NET, Java and C #. He has been using Visual Studio (.NET) since the Beta back in year 2000. He and the team have developed many projects using .NET platform such as SCM, and HR based applications. He is familiar with the N-Tier design of business application and is also an expert with database experience in MS SQL, Oracle and AS 400.
This entry was posted in .Net and tagged , . Bookmark the permalink.

70 Responses to 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: 5)

  1. Rupendra Bensh says:

    GO START -> ALL PROGRAMS -> SQL SERVER 2008/2005/2008 R2
    ->CONFIGURATION TOOLS->
    ->SELECT SQL SERVER CONFIGURATION MANAGER
    ->SELECT SQL SERVER NETWORK CONFIGURATION
    ->SELECT PROTOCOLS FOR MSSQLSERVER(YOUR INSTANT NAME)
    ->IN RIGHT TASK PANEL
    ->MAKE SURE MENTION BELOW:

    DISABLE SHARED MEMORY AND VIA
    ENABLE NAMED PIPE AND TCP/IP

    —-MAKE SAME THING IN
    ->SQL NATIVE CLIENT 10.0(SERVER VERSION) CONFIGURATION – CLIENT PROTOCOLS

    RESTART SQL SERVER(MSSQLSERVER [YOUR INSTANT NAME]) SERVICE

  2. Caitlin says:

    Brilliant. Thanks!

  3. somil says:

    i already did the same but still getting error and not getting connected to remote server

  4. Pvt Yori says:

    i still got the same error when trying to add a new remote mysql data source in visual studio 2010. When i try to make a remote sql connection in MySQL Workbench it works..

  5. Maikol says:

    I did the same configuration also. But it didn’t work.
    The server can be ping.

    What else should I do?

  6. Ritu says:

    I did same thing but still i am getting same error please help me how to short out this problem

  7. Ben says:

    i had this problem, turned out my connection string was:
    “Data Source=BEN-PC/SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True”
    instead of what it should have been:
    @”Data Source=BEN-PC\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True”
    not sure if this is even relevant but hopefully someone will find help from this ;D

  8. Sachin says:

    I installed VS 2010 and then SQL Server 2008 R2 on my machine and tried all the steps from opening ports in firewall and settings given in this discussion but I am not able to connect using Windows or SQL server authentication is not working. I am not able to connect the server on the same machine. Please help.

  9. Balaji says:

    oh man it worked like charm on SQL server 2008 thanks a Ton :)

  10. janu mary says:

    Still i am getting the same 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) how to correct .
    “Data Source=ANU-PC\SQLEXPRESS;Initial Catalog=sample;Integrated Security=True”;

    plzzzzzzzzzz help

  11. Sachin says:

    I tried all the stuff and what worked for me is that I uninstalled both SQL Server and VS 2010 and left the firewall enabled and then install the SQL Server 2008 R2 and with default instance and after that VS 2010 and it worked smoothly. I think it is the sureshot way to get it worked. If someone still face any issue then do write here.

  12. Bharathi says:

    i dont know the password of sqlserver authentication i am able to connect windows authentication
    only with out reinstall sql server can i able to find the password of sql server authentication?
    thanks it advance..

  13. Fernando Olvera says:

    Thanks a lot! It works.

  14. best172 says:

    i have sqlserver enterprise 2008 , it works fine in the local pc, but when i want to connect to it from other pc in the local network it gives error that says error in connection was created due to sqlserver 2005..i don’t have sqlserver 2005 …what does this mean?

  15. Yami says:

    I did all settings which you mentioned above but still have bellowed error for remotely connection to SQLEXPRESS server.
    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) (Microsoft SQL Server, Error: 53)

    Can anybody giude me please…!

  16. Waseem Khan says:

    Awesome No words to impress my happiness , its really working , thanks for uploading this helpful video.

  17. Venkatesh Hariharan says:

    Awesome Solution……Thanks a ton…Thanks a million….Gr8 work….Was struggling for this solution since a week….Its solved…Thanks again…

  18. DINA says:

    I did all the steps mentioned but i still got this error :
    I have
    PC1 (client) : Win Seven Professional with VS 2010 and SQL Server express ( that come with VS 2010) i enabled TCP/IP and PIPES on client PC
    PC2 : XP ( on virtual machine) where i installed SQL SERVER 2008 EXPRESS with management studio i enabled also the TCP/IP and Pipes and i attached the database of my application

    my connection string is like :
    connectionString=”Data Source=192.168.47.136;Initial Catalog=BD1_QUALITE;Persist Security Info=True;User ID=sa;Password=************”

    I don’t know what to do more

    what i”m tryin to do is to run my application from Win Seven ( Client PC) and related it to sql server database that is located on XP virtual machine

    Pleaaase i need help

    sincerly

  19. zykes says:

    I have SQL 2008, my problem right now is connecting to a different server. I can connect to my local server but when connecting to another server, This error occurs. I can ping the other server i am connecting to. Any help guys?

  20. Worked for me in SQL 2012too

  21. Adhiraj says:

    Thankyou so much,,,,,, It is working after exploring for an hour on the Google……….. else I’m going to re install SQL SERVER again.

  22. saksena says:

    This is great!!

  23. saksena says:

    Hi am new to vs2010, having an doubt pls help!
    In sql am having these:-
    server name = (local)
    autentication=sql server authentication
    login = sa
    password = “”
    db=sena

    and in vs2010 webconfig am having this:-

    and in cs page i have mentioned like this:-
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);

    when i try to run the code am getting error like this

    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: Shared Memory Provider, error: 40 – Could not open a connection to SQL Server)

    pls help me!!!

  24. saksena says:

    Hi am new to vs2010, having an doubt pls help!
    In sql am having these:-
    server name = (local)
    autentication=sql server authentication
    login = sa
    password = “”
    db=sena

    and in vs2010 webconfig am having this:-

    and in cs page i have mentioned like this:-
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);

    when i try to run the code am getting error like this

    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: Shared Memory Provider, error: 40 – Could not open a connection to SQL Server)

  25. saksena says:

    Hi am new to vs2010, having an doubt pls help!
    In sql am having these:-
    server name = (local)
    autentication=sql server authentication
    login = sa
    password = “”
    db=sena

    and in vs2010 webconfig am having this:-

    and in cs page i have mentioned like this:-
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);

    when i try to run the code am getting error like this

    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: Shared Memory Provider, error: 40 – Could not open a connection to SQL Server)

  26. saksena says:

    sorry this lines i copied from webconfig but not getting displayed in above post’s thats y am posting this separately

  27. saksena says:

    add name=”dbconnection” connectionString=”data source=(local)\SQLEXPRESS;Integrated Security=true;Initial Catalog=sena;User Instance=true” providerName=”System.Data.SqlClient”

  28. prathik says:

    ← How to configure Windows 7 to type Chinese characters – VideoWrite value to Excel spreadsheet →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: 26 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error:

  29. bhadresh says:

    Excellent Advice my problem is solved….. Appriciate your work…
    Don’t stop and help others..

    Thank You

  30. Kevin Burton says:

    What if the remote server is Azure and you cannot configure anything, and the error is coming from bcp?

    Thank you.

  31. anurag says:

    thnx a lot it worked for me…
    thn q very much…..

  32. Jagadish says:

    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)

  33. Naveen says:

    Great Job………………Thank you very much

  34. sonali says:

    i have deployed a web application on server but there is a runtime error i.e. 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 the connection string and database connectivity, but still these error occure.
    so what should i do for resolve these error
    please give me some solution as soon as posible,i have searched from 4 days.

  35. sonali says:

    i have deployed a web application on server but there is a runtime error i.e.
    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)
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: 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: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [SqlException (0x80131904): 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)]
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5061946
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
    System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity) +341
    System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +129
    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +239
    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
    System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
    System.Data.SqlClient.SqlConnection.Open() +125
    ATS.DAL.openCon() in DAL.cs:15
    ATS.DSL.getResult(String str) in DSL.cs:24
    ATS.Account.Login.LoginUser_Authenticate(Object sender, AuthenticateEventArgs e) in Login.aspx.cs:24
    System.Web.UI.WebControls.AuthenticateEventHandler.Invoke(Object sender, AuthenticateEventArgs e) +0
    System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +115
    System.Web.UI.WebControls.Login.AttemptLogin() +127
    System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
    System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +125
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +167
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

    i have checked the connection string and database connectivity, but still these error occure.
    so what should i do for resolve these error
    please give me some solution as soon as posible,i have searched from 4 days.

  36. chanmingman says:

    It is very much depend on your environment though.. your firewall, network segment and so. This need to be physically diagnosed.

  37. Mona says:

    while resolving the same error through this
    GO START -> ALL PROGRAMS -> SQL SERVER 2008/2005/2008 R2
    ->CONFIGURATION TOOLS->
    ->SELECT SQL SERVER CONFIGURATION MANAGER
    ->SELECT SQL SERVER NETWORK CONFIGURATION
    ->SELECT PROTOCOLS FOR MSSQLSERVER(YOUR INSTANT NAME)
    I am getting PROTOCOLS FOR SQLEXPRESS only except PROTOCOLS FOR MSSQLSERVER(YOUR INSTANT NAME).
    Basically i want to connect to sql server 2008 R2 from VS2008.

  38. arslan says:

    Cannot connect to PC\SQLEXPRESS2008.

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

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