Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make MS SQL Server available for connections?

I'm trying to connect to MS SQL Server (running on my machine) from a Java program. I'm getting the following long winded exception:

Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".

When I check "Properties" and click "View Connection Properties" in the Object Explorer of MS SQL, I find that the "Server is Unavailable." This seems possibly related to the exception message.

How can I make the server available?

Edit:

I am using SQL Server 2008, and I have now enabled TCP/IP, and restarted my instance. I am still told that "Server is unavailable."

Any other ideas?

like image 577
Eric Wilson Avatar asked Jul 06 '09 12:07

Eric Wilson


People also ask

How do I enable SQL Server for remote connections?

Using SQL Server Management StudioIn Object Explorer, right-click a server and select Properties. Select the Connections node. Under Remote server connections, select or clear the Allow remote connections to this server check box.

How do I enable SQL connection?

Security & ConnectionsRight-click on your server name and click 'Properties'. Go to the Security page for Server Authentication, and select 'SQL Server and Windows Authentication' mode. Then, go to the Connections page and ensure that "Allow remote connections to this server" is checked, and click OK.

How do I restrict connections in SQL Server?

Using SQL Server Management StudioSelect the Connections node. Under Connections, in the Max number of concurrent connections box, type or select a value from 0 through 32767 to set the maximum number of users that are allowed to connect simultaneously to the instance of SQL Server. Restart SQL Server.


1 Answers

I ran into this problem as well. The MSKB article applies to SQL server 2005.

As the "SQL Server Surface Area Configuration" tool has been dropped in lieu of "Facets" - this wasn't obvious to me.

I resolved this by setting the TCPAll port and enabling the relevant IP.


Steps

  1. Open the Sql Server Configuration Manager (Start -> Programs -> Microsoft SQL Server 2008 -> Configuration Tools)

  2. Expand SQL Server Network Configuration -> [Your Server Instance]

  3. Double click TCP/IP

    • Under Protocol:

      Ensure Enabled is Yes

    • Under IP Addresses:

      Scroll to the bottom and set the TCP Port under IPAll, (1433 by default)

      Find the IP address you want to connect to and set Enabled and Active to Yes

like image 84
ptg Avatar answered Oct 14 '22 12:10

ptg