Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not open a connection to SQL Server

I have problems connecting to my database server. The database server is not local, I am connected via its IP address.

It works fine in my development machine. After publishing the website to my server, it can not connect to my database server.

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)

Why can't my publish server connect to the database server, whereas it works fine through the development machine?

like image 304
nezdet Avatar asked Aug 31 '10 18:08

nezdet


2 Answers

I often had that problem. Mostly it's because of two problems.

  1. Open the SQL Server Configuration Manager.

    • Check if the SQL Server Network Configuration supports TCP/IP, if it's disabled, enable it. e.g. SqlServer 2005 Network Configuration, Protocols for SQLEXPRESS
  2. Open the SQL Server Management Studio

    • Click on the Sql Server Properties (right click on the server name and select properties).
    • After that, select the page "Security" and switch the check to "SQL Server and Windows Authentication mode".

That's all.

like image 140
BitKFu Avatar answered Sep 27 '22 17:09

BitKFu


I'll attempt to go two for two on the psychic debugging for today...

I will assume that you are not using integrated security? If so it might explain things as the account on your local machine probably has permissions, but the SYSTEM account that is running on the server does not. Just a shot in the dark though.

like image 32
Josh Avatar answered Sep 27 '22 17:09

Josh