java - Cannot open port 1433 for Azure SQL database in Mac -


i'm trying access azure-hosted sql database on java application. checked port 1433 using nmap , shows it's closed:

starting nmap 7.12 ( https://nmap.org ) @ 2016-09-02 09:44 pht nmap scan report localhost (127.0.0.1) host (0.00014s latency). other addresses localhost (not scanned): ::1 port     state  service 1433/tcp closed ms-sql-s 

i have edited /etc/pf.conf , restarted mac port still closed. here pf.conf:

scrub-anchor "com.apple/*" nat-anchor "com.apple/*" rdr-anchor "com.apple/*" dummynet-anchor "com.apple/*" anchor "com.apple/*" load anchor "com.apple" "/etc/pf.anchors/com.apple" pass in proto tcp any port 1433 

also, firewall set off.

my java app throwing error:

error starting database: tcp/ip connection host flowengine7.database.windows.net, port 1433 has failed. error: "connection timed out: no further information. verify connection properties. make sure instance of sql server running on host , accepting tcp/ip connections @ port. make sure tcp connections port not blocked firewall.". 

java code:

 string connectionstring =                 "jdbc:sqlserver://dbname.database.windows.net:1433;database=dbname;user=user@@user;password=passwordhere;encrypt=true;trustservercertificate=false;hostnameincertificate=*.database.windows.net;logintimeout=30;";          connection connection = null;          try {             connection = drivermanager.getconnection(connectionstring);             println 'connected';         }         catch (exception e) {             e.printstacktrace();         }         {             if (connection != null) try {                 connection.close();             } catch (exception e) {             }         } 

you're overlooking azure sql server-level firewall:
https://azure.microsoft.com/en-us/documentation/articles/sql-database-configure-firewall-settings/

firewall-entry

you need whilelist mac's public ip address in there able connect local. default azure services can reach 1433/tcp on azure sql instance (permitted allow access azure services setting in azure sql firewall).

if you're getting new public ip address every time reboot dsl/cable/fiber modem you'll need define whole range of addresses not 1 (i.e. 174.73.0.0 - 174.73.255.255 vs. listing 174.73.16.180). you'll grab ip address in same range.


Comments