Saturday, 8 December 2007

SQL SERVER - Fix : Error : 40 - could not open a connection to SQL server

Recently i was setting up development environment at home. When i had to connect SQL server remotely from another VPC, i could not connect it even after enabling allow remote connections on my Sql Server. the error messaage was...

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)


for some reason it did not work as suggested by many..

but after banging my head to wall... cpu and then to lcd monitor, figured the solution.

but dont worry, figured what was the problem at last………

the probelm is the Instance name from the client is not resolved, to do that follow the below shown steps.

1. Navigate to C:\Windows\System32\drivers\etc
2. Open hosts file in notepad
3. Add the entry at the end of line, as i did for example

192.168.131.65 KSSQLSRVR
192.168.131.65 KSSQLSRVR\SPDEV01

those were my instances i am tried to connect remotely

sweeeeet... it worked!

should work for anyone who have this problem...

2 comments:

Edmund said...

worked brilliantly. thanks!

CD said...

It didn't work in my case ..:( I have a local machine and a local database. I added the following line
127.0.0.1\\SQLEXPRESS localhost
to the already existing line
127.0.0.1 localhost
and it looks like this now
127.0.0.1 localhost 127.0.0.1\\SQLEXPRESS localhost