locked
A network-related or instance-specific error occurred while establishing a connection to SQL Server RRS feed

  • Question

  • User-1856125883 posted

    Hello everyone. I'm working on my ASP.NET MVC project.

    When I run my project in localhost, there 's no problems. But when I run web as client after I publish my web app on Windows Azure, I got the following error when I try to log in

    "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)] etc"

    Please help me to fix it 

    Monday, November 20, 2017 3:23 AM

All replies

  • User364663285 posted

    Hi,

    You can try to create different Connection which is something like

    <connectionStrings>

    <add name="conn2" connectionString="Data Source=192.168.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>

    </connectionStrings>

    within Web.config/app.config file in your project.

    Monday, November 20, 2017 5:27 AM
  • User991499041 posted

    Hi smham,

    "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)] etc"

    Make sure your database engine is configured to accept remote connections:

    Right click on the server node and select Properties

    Go to Left Tab of Connections and check "Allow remote connections to this server"

    Regards,

    zxj

    Monday, November 20, 2017 5:45 AM
  • User-1856125883 posted

    Thank you for your reply. But this is not work for me I also try difference methods to allow remote connection on SQL Server but it still not working

    Monday, November 20, 2017 6:42 AM
  • User991499041 posted

    Hi Smham,

    Thank you for your reply. But this is not work for me I also try difference methods to allow remote connection on SQL Server but it still not working

    You have mentioned that you tried a lot of ways, could you elaborate?

    I noticed you mentioned Windows Azure, not sure if it was about Azure configuration.

    Besides, please follow the instructions in the article below to troubleshoot this connection error.

    https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/troubleshoot-connecting-to-the-sql-server-database-engine 

    Regards,

    zxj

    Monday, November 20, 2017 9:36 AM
  • User753101303 posted

    Hi,

    For now it seems no communication is possible between the web server and the SQL database (for example being blocked by a firewall). First could you clarify if you are using an Azure hosted database or if you are really trying to reach your own local database server from Azure ?

    Monday, November 20, 2017 1:19 PM
  • User-236208671 posted

    There could be several reasons for SQL Server error 40, you can go through this helpful article to know how to fix this error: http://www.sqlserverlogexplorer.com/fix-error-message-40/

    Thursday, December 7, 2017 12:15 PM
  • User-277334969 posted
    • Check the following
    • SQL Server are up are running
    • check the correct instance name
    • add in exception in firewall
    • check if anti virus is using it
    • check the sql browser services
    Wednesday, September 19, 2018 10:23 AM