This Azure tutorial will discuss how to fix the error. Cannot open server requested by the login. the login failed, which I got while trying to log in to the Azure SQL database.
Cannot Open Server requested by the login. The login failed.
Recently, I was working on a requirement to write a stored procedure in my Azure SQL DB. I encountered this error when attempting to log in to the Query Editor (Preview).
- Log in to the Azure Portal (https://portal.azure.com/)
- Search for the SQL databases in the Azure Portal and click on the search result

You will see all your list of Azure SQL databases here. Click on the one that you want to use. Now, click on the Query editor (preview) link from the left navigation on the SQL database page. Enter your login username and password, and click the Login button. You can see that I got the error below.

The Exact error message was as below.
Cannot open server ‘sql1246’ requested by the login. Client with IP address ‘106.##.106.###’ is not allowed to access the server. To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. It may take up to five minutes for this change to take effect. Set server firewall (sql1246)
Now we will see how to fix this error.
Solution
To fix the error, you need to set the firewall for the SQL server(sql1246) in my case. Follow the steps below.
1. To set the firewall, click the Set server firewall link in the error message itself; otherwise, you can search for SQL Server in the Azure Portal and click on the search result.
You will get the list of SQL servers and click on the specific one for which you need to set the Firewall( You can see the complete error message to find the name of the SQL Server).
2. On the SQL Server page, click the Firewalls and Virtual Networks link in the left navigation. The next step is to click the + Add client IP button, as highlighted below, and enter the Client IP address in the Rule name, Start IP, and End IP text boxes. (For the exact Client IP, refer to the complete error message). Finally, click on the Save button as shown in the screenshot below.

Once you click the Save button, a pop-up will appear below. Click on the OK button.

3. Now navigate to the Azure SQL Database and click on the Now click on the Query editor (preview) link from the left navigation on the Azure SQL database page. Enter your login username and password, and click the Login button. You will be able to log in successfully as shown below

Wrapping Up
In this article, we discussed how to resolve the error ‘Cannot open server requested by login,‘ which I encountered while attempting to log in to the Azure SQL database.
You may also like the following article below

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
