Error Has Occurred While Establishing A Connection To SQL Server 2005 Which Does Not Allow Local and Remote Connections

When connecting to an instance of Microsoft SQL Server 2005 database, including SQL Server 2005 Express, Developer and Enterprise editions, for authentication or accessing and retrieving and updating the data, the the following error message may appear. The problem happens no matter the connection is originated from remote computer or on SQL Server local computer itself, and can be caused by any program, such as SQLCMD utility, used to connect to SQL Server.

Sqlcmd: Error: Microsoft SQL Native Client: 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.


Or,

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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)

This problem may occur when SQL Server 2005 is not configured to accept incoming local and remote connections, which is disabled by default in SQL Server 2005 Express Edition, SQL Server 2005 Developer Edition and also SQL Server 2005 Enterprise Edition. To solve the connection forbidden problem, SQL Server 2005 needs to configure to allow incoming local and remote connections.

Firstly, ensure that SQL Server 2005 is configured properly to allow incoming connections on the instance of database server, else enable and turn on the local and remote connections setting.

  1. Click Start button, then go to Programs or All Programs, then select Microsoft SQL Server 2005, followed by Configuration Tools. Click and run the SQL Server Surface Area Configuration.
  2. On the “SQL Server 2005 Surface Area Configuration” page, click Surface Area Configuration for Services and Connections.
  3. On the “Surface Area Configuration for Services and Connections” page, expand Database Engine tree, click Remote Connections.
  4. Select Local and remote connections, or Local connections only which applicable only if there is no remote system tries to connect to the SQL Server, useful when you just trying to connect and authenticate with the server after installing.
  5. Select the appropriate protocol to enable to local and/or remote connections environment. To ensure maximum compatibility, select Using both TCP/IP and named pipes.
  6. Click Apply button when done.
  7. Click OK button when prompted with the message saying that “Changes to Connection Settings will not take effect until you restart the Database Engine service.”
  8. On the “Surface Area Configuration for Services and Connections” page, expand Database Engine, then click Service.
  9. Click Stop button to stop the SQL Server service.
  10. Wait until the MSSQLSERVER service stops, and then click Start button to restart the MSSQLSERVER service.

Secondly, SQL Server Browser service has to be enabled to allow for local and remote connections if SQL Server 2005 is running by using an instance name and users are not using a specific TCP/IP port number in the connection string.

  1. Click Start button, then go to Programs or All Programs, then select Microsoft SQL Server 2005, followed by Configuration Tools. Click and run the SQL Server Surface Area Configuration.
  2. On the “SQL Server 2005 Surface Area Configuration” page, click Surface Area Configuration for Services and Connections.
  3. On the “Surface Area Configuration for Services and Connections” page, click SQL Server Browser.
  4. Select Automatic as the Startup type to start SQL Server Browser service automatically every time system starts.
  5. Click Apply button.
  6. Click on Start button to start the service immediately.
  7. Click OK button.

Finally, if remote computer needs to connect and access SQL Server, an exceptions in Windows Firewall included in Windows XP SP2 (Service Pack 2), Windows Server 2003 and Windows Vista needs to be created. If you’re using third-party firewall system, the exception rules also needed to be created to allow external remote connections to the SQL Server 2005 and SQL Server Browser Service to communicate through the firewall, else connections will be blocked. Consult the firewall manual for more details. Each instance of SQL Server 2005 must have its own exception, together with an exclusion for SQL Server Browser service.

SQL Server 2005 uses an instance ID as part of the path when you install its program files. To create an exception for each instance of SQL Server, you must identify the correct instance ID. To obtain an instance ID, follow these steps:

  1. Click Start button, then go to Programs or All Programs, then select Microsoft SQL Server 2005, followed by Configuration Tools. Click and run the SQL Server Configuration Manager.
  2. In “SQL Server Configuration Manager”, click the SQL Server Browser service in the right pane, right-click the instance name in the main window, and then click Properties.
  3. On the “SQL Server Browser Properties” page, click the Advanced tab, locate the instance ID in the property list.
  4. Click OK button.

Then create an exception for SQL Server 2005 in Windows Firewall.

  1. Click on Start button, the click on Run and type firewall.cpl, and then click OK. For Windows Vista, type firewall.cpl in Start Search box and press Enter key, then click on Allow a program through Windows Firewall link on left tasks pane.
  2. In “Windows Firewall”, click the Exceptions tab, and then click Add Program.
  3. In the “Add a Program” window, click Browse button.
  4. Click the C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe executable program, click Open button. MSSQL.1 with is a placeholder for the instance ID that is obtained from previous procedure. Note that the path may be different depending on where SQL Server 2005 is installed.
  5. Click OK button.
  6. Repeat steps 1 through 5 for each instance of SQL Server 2005 that needs an exception.
  7. For SQL Server Browser service, locate the C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe executable program, and click Open button.
  8. Click OK button.

8 Responses to “Error Has Occurred While Establishing A Connection To SQL Server 2005 Which Does Not Allow Local and Remote Connections”

  1. Victor
    December 3rd, 2008 20:14
    8

    I restarted the service from services menu, for some reason that did not work. Your solution worked perfectly. Thanks.

  2. Ibrahim
    November 20th, 2008 00:57
    7

    for some reason this solution is working for me.

  3. vipwan
    November 12th, 2008 09:26
    6

    看了,好像没什么帮助

  4. mash
    October 30th, 2008 23:47
    5

    thanks a lot, helped me so much

  5. Ajit Kadam
    October 20th, 2008 18:45
    4

    It’s Fabulous,
    Thank You!

  6. Valeria
    October 14th, 2008 02:48
    3

    Muuuuchas Gracias :-)

  7. Vikram D
    July 22nd, 2008 23:16
    2

    Thanks! Your solution worked fine for me! Appreciate all the help!

  8. Angel
    April 17th, 2008 02:34
    1

    Thank you for this. Very useful.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

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) - A network-related or instance-specific error occurred while establishing a connection to SQL Server - 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) - 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) (.Net SqlClient Data Provider) - 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 - 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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.) - A network-related or instance-specific error occurred while establishing a connection to SQL Server. - an error occurred while establishing a connection to the server. when connecting to sql server 2005 - 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) (Microsoft SQL Server, Error: -1) - 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) - 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) - 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: TCP Provider, error: 0 - No such host is known.) - An error has occurred while establishing a connection to the server. When connecting to SQL Server 2008, 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) - 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)| - "sql server" "error 10061" - "a network-related or instance-specific error occurred while establishing a connection to SQL Server." - 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). - Microsoft SQL server Error 10061 - microsoft sql server error 87 - provider: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it - sql server error 10061 - Microsoft SQL Server, Error: 87 - MS sql server error 87 - provider: SQL Network Interfaces, error: 25 - Connection string is not valid - Unable to connect to server. Reason: 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) - "A network-related or instance-specific error occurred while establishing a connection to SQL Server" - network-related or instance-specific error occurred while establishing a connection to sql server - sqlcmd an error has occurred while establishing a connection to the server - (provider: SQL Network Interfaces, error: 25 - Connection string is not valid) - [SQL Server Native Client 10.0]A network-related or instance-specific error - 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: Named Pipes Provider, erro - An error has occurred while establishing a connection to the server. provider: TCP Provider, error: 0 - No such host is known. - Named Pipes Provider: Could not open a connection to SQL Server Sqlcmd - network-related or instance-specific error occurred - no such host is known, sql remote connection - sql server does not allow remote connection(provider tcp provider,no such host is known ) - sql 2008 network interfaces, error: 25 - connection string is not valid - sql server 2005 error occurred establishing a connection to server - "System.Exception: -1:An error has occurred while establishing a connection." - "an error has occurred while establishing a connection to the server" 2008 - "SQL server" SQL network interface error 26 Error locating server - [microsoft][SQL Native Client]TCP Provider error 10061 - 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) (Microsoft SQL Server, Error: -1) - 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: TCP Provider, error: 0 - No such host is known.) - .NET sql server does not allow remote connections no such host is known - a network-related or instance-specific error occured - A network- related or instance-specific error occurred while establishing a connection to SQL Server - A network-related or instance-specific error occurred while establishing - a network related or instance especific error ocurred - A network-Related or instance-specific error occured while establishing connection to SQL server 2008 -