Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host HOSTNAME, port 1433 has failed.
Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. 
Make sure that TCP connections to the port are not blocked by a firewall.

Possible Cause 1

Most of the times the problem is exactly as stated in the Exception text. The given Port for your connection has to be allowed in the firewall settings.

Possible Cause 2

Sometimes this error occurs because of the TCP/IP configuration in the Sql Server Configuration Manager Console.

  • Open the Sql Server Configuration Manager Console.
  • Expand the SQL-Server Network Configuration item in the tree on the left side.
  • Right click on the TCP/IP entry on the left side.
  • Click on the tab for the IP adresses
  • Scroll down to the IPAll configuration
    • Make sure that the configuration of TCP DynamicPorts is empty
      • sometimes it is preconfigured with a value 0 or a value above 50000
    • Make sure that the correct port number for the connection is configured for the TCP Port

Possible Cause 3

If you are trying to specify a SQL Server instance name with the hostname in the JDBC URlL like this

...