Friday, March 14, 2008

error: 26 - Error Locating Server/Instance Specified

"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. "

           Programmers often get this error message when connecting to a SQL Server named instance.  Every time a client connects to the SQL Server named instance, an SSRP UDP packet is sent to the server machine UDP port 1434. This is done to know the configuration information of the SQL instance, e.g., protocols enabled, TCP port, pipe name etc. 

Without these information, the client does not know how to connect to the server and it fails with the above error message.
Make a checklist of the following

1. Check your server name is correct (typo).
  •  Check to see the instance name is correct and and running
  •   Check the server DNS (ping the server).
2. Check to ensure  your database engine is configured to accept remote connections.
  •  Go to Start  -> All Programs ->  SQL Server 2005 ->  Configuration Tools ->  SQL Server  Surface  Area Configuration     
  •  Click on Surface Area Configuration for Services and Connections
  •  Select the named instance   -> Database Engine  ->  Remote Connections
  •  Click  Enable local and remote connections
  •   Restart the server
3.Check the Connection string. If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings     (machineName\Named Instance)

4.If firewall is enabled on the server make an exception  for the SQL Server instance and port
  •   Go to   Start  -> Run -> Firewall.cpl
  •   Click on exceptions tab
  •   Add the sqlservr.exe  and the default  port (1433)
5. Check the SQL Browser service is running on the server, if firewall is on make an exception for the SQL Browser.exe   and/or UDP port 1434 .