locked
SQL Connection Error RRS feed

  • Question

  • User-1236024542 posted

    Hello,

    When I host my web application on server an error occurred:

    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)

    But its working completely fine on local host. Does any one have any idea what to do? I already search on the google followed the steps but still its not running.

    Thanks in advance

    Ritul Patel

    Thursday, September 14, 2017 4:25 PM

Answers

  • User753101303 posted

    Hi,

    This message happens when you can't reach at all the database server. It is common to not use the same server when developing on localhost and being hosted on the final web server. In this case you have to change the connection string. Have you done that ?

    If you are sure the database server is already correct, it could be a firewall rule that prevents access to the database server from the web server.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 14, 2017 4:37 PM

All replies

  • User753101303 posted

    Hi,

    This message happens when you can't reach at all the database server. It is common to not use the same server when developing on localhost and being hosted on the final web server. In this case you have to change the connection string. Have you done that ?

    If you are sure the database server is already correct, it could be a firewall rule that prevents access to the database server from the web server.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 14, 2017 4:37 PM
  • User-1236024542 posted

    hi ,

    Thanks for your helpful answer.

    I used the same server but forgot to change the connection string but still When I try to enter id and password on my "Login.aspx" page and click onto login button then "Login.aspx" page reload and I wan't able to go to next page. This error occurs when I run on final web server but when I Run on localhost its working fine.

    Thursday, September 14, 2017 6:05 PM
  • User753101303 posted

    This is the same database server but you had to change the connection string because it was using localhost as well ? If you are using SQL Server Express, you have to explicitly allow access from other machines.

    Seeing the connection string could perhaps help. Change sensitive parts but please keep the structure intact ie if your server is W10RITUL29\DEV replace that with server\instance in the connection string you'll show (so that we still know you are using a SQL Server instance).

    Thursday, September 14, 2017 6:32 PM