This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.
Today, I worked on a service request that our customer got the following error message using Java code:
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host servername.database.windows.net, port 1433 has failed. Error: "Permission denied: connect. Verify the connect
ion 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."
or
"Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host nodename.tenantring.northeurope1-a.worker.database.windows.net (redirected from servername.database.windows.
net), port 11001 has failed. Error: "Permission denied: 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.". at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2462)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:668)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2695)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2362)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2213)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1276)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:861)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)"
I would like to share with you what was my lessons learned here.
The first thing is to isolate the problem running the suggested Java code to see the results:
The error message: Permission denied: connect reports that when when trying to open the port any firewall/NSG is blocking this outbound port, either, 1433 or redirect port 11000-12000.
If the issue is regarding with port 1433 means that the initial connection with port 1433 is rejecting, if the error message any port from 11000-12000 means that the issue is rejecting any of this port.
As a workaround, if your customer only has the port 1433 as outbound open, please, change the connection policy to Proxy meanwhile their networking team is opening as outbound connection from 11000-12000.
For reference: Azure SQL Database connectivity architecture - Azure SQL Database and Azure Synapse Analytics | Micr...
Enjoy!