Port being blocked for Azure SQL Database

Port being blocked for Azure SQL Database

The user got the following error message when try to connect to Azure SQL Database from their Virtual machine, they said they already set the firewall, the user has access to the database and etc but they confused with this error message.

 
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - An attempt was made to access a socket in a way forbidden by its access permissions.) (Microsoft SQL Server, Error: 10013)

How to find out the root cause?

I talked about SQL Connectivity checker before but this time I want to show you how you are troubleshooting with this free and great PowerShell script. In the first step download it from Github

If you’re in windows, Linux and even server without internet connection it has different guide. In windows just search for Windows PowerShell ISE and run it.

how to run SQL Connectivity checker?

Copy/paste the code which provided in Github, you only need to do 3 steps.

- New script / Paste the code in top part

- Put 4 parameters, server, database name, user and password. Don’t to put port or any additional details.

- Click on the green play button and wait until the result show up

SQL Connectivity checker to find out connectivty issue

It takes a few minutes then you have the result, you’ll have zip file which normally Microsoft engineer wants to have that file. here is example of the result in my case.

 
Trace complete.
 Gateway connectivity to x.x.x.100:1433 FAILED
 Please make sure you fix the connectivity from this machine to x.x.x.100:1433 to avoid issues!
 Failure to reach the Gateway is usually a client-side networking issue (like DNS issue or a port being blocked) that you will need to pursue with your local network administrator.
 See more about connectivity architecture at https://docs.microsoft.com/azure/azure-sql/database/connectivity-architecture

As the message shows that’s DNS issue or a port being blocked, in this case Network admin from customer check and found 1433 is blocked in their firewall after they opened that the customer could login successfully to Azure SQL Database.

That’s a simple test that you can find if there is any issue in your side or anything blocked the port.