Cannot open port 1433 for Azure SQL database in Mac

I’m trying to access a Azure-hosted SQL database on my java application. I checked the port 1433 using nmap and it shows that it’s closed:

Starting Nmap 7.12 ( ) at 2016-09-02 09:44 PHT
Nmap scan report for localhost (
Host is up (0.00014s latency).
Other addresses for localhost (not scanned): ::1
1433/tcp closed ms-sql-s

I have edited the /etc/pf.conf and restarted my mac but the port is still closed. Here is my pf.conf:

  • Error in logic PHP / SQL Server
  • Issues with SQL Server MERGE statement
  • How to Set a variable using OPENQUEY in SQL Server
  • Measuring Query Performance : “Execution Plan Query Cost” vs “Time Taken”
  • How to list available instances of SQL Servers using SMO in C#?
  • Left join a query with a cross apply
  • scrub-anchor "*"
    nat-anchor "*"
    rdr-anchor "*"
    dummynet-anchor "*"
    anchor "*"
    load anchor "" from "/etc/pf.anchors/"
    pass in proto tcp from any to any port 1433

    Also, my firewall is set to off.

    My java app is throwing this error:

    Error starting database: The TCP/IP connection to the host, port 1433 has failed. Error: "Connection timed out: no further information. 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.".

    Java code:

     String connectionString =
            Connection connection = null;
            try {
                connection = DriverManager.getConnection(connectionString);
                println 'connected';
            catch (Exception e) {
            finally {
                if (connection != null) try {
                } catch (Exception e) {

    One Solution collect form web for “Cannot open port 1433 for Azure SQL database in Mac”

    You’re overlooking the Azure SQL server-level Firewall:


    You need to whilelist your Mac’s Public IP address in there to be able to connect from local. By default only Azure services can reach 1433/TCP on your Azure SQL instance (permitted by Allow access to Azure Services setting in the Azure SQL Firewall).

    If you’re getting a new Public IP address every time you reboot your DSL/Cable/Fiber modem you’ll need to define a whole range of addresses not just the one (i.e. – vs. listing Hopefully you’ll always grab an IP address in the same range.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.