You may receive this error when trying to remotely connect to your SQL Server 2005 (or Express) database. (Even when connection remotely from a service running locally, such as an ASP.NET website.) The first thing to check is the most common cause of this error. You must enable Remote Connection manually to SQL Server 2005 installations because they are disabled by default. To do this, check the following.
Enable remote connections for SQL Server 2005
- Open the SQL Server Surface Area Configuration tool. (You can find this in your start menu under SQL Server 2005.)
- Expand "Database Engine"
- Click on "Remote Connections"
- Enable Remote Connections (TCP/IP, Named Pipes, or Both)
- Click on Service under "Database Engine" and Stop then Start your database for the changes to take affect.
Test your connection now. For most people this will be sufficient to correct the problem. In my case, my company is using a connection string that did not specify the port when connecting to the database. I had just reinstalled Microsoft SQL Server and received this error and didn't want to have to change anything in the project to get it working again. I found that I had to statically set it for the server to SQL Server's default value of 1433. To do this, perform the following.
Set the port to be used with TCP/IP connections
- Open the SQL Server Configuration Manager
- 2xpand SQL Server 2005 Network Configuration and select "Protocols for YOURDBSERVERNAME"
- Right click on "TCP/IP" on the right and choose properties
- Click on the "IP Addresses" tab
- Set the TCP Port property for the entry with IP Address "127.0.0.1" or any other that you need and click "Apply".
In our case, this fixed the problem and allowed us to use our connection string unmodified.