Skip to content
Microsoft SQL Server

SQL Server Error 40615

Cannot open server requested by the login (Azure SQL firewall)

Severity 16 Connectivity
Applies to: Azure SQL Database (logical servers with a public endpoint). Not raised by SQL Server or Azure SQL Managed Instance.
Last technically reviewed 23 October 2026 on SQL Server 2025 (17.0.1145.4) message catalogue; Microsoft Learn (Azure SQL Database)
The full message
Cannot open server 'myserver' requested by the login. Client with IP address '203.0.113.24' is not allowed to access the server. To enable access, use the 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.
Error number
40615
Severity
16 (user-correctable error)
State
Not documented by Microsoft (not reproduced: Azure SQL Database only)
Product
Azure SQL Database
Versions
Azure SQL Database (logical servers with a public endpoint). Not raised by SQL Server or Azure SQL Managed Instance.
Category
Connectivity
Last reviewed
23 October 2026

What it means

Error 40615 means the Azure SQL Database firewall rejected the connection because the public IP address shown in the message matches no server-level or database-level firewall rule.

A new logical server in Azure SQL Database blocks all access to its public endpoint until you add firewall rules. Each connection is checked by source IP address: first against the database-level rules of the database it asks for, then against the server-level rules. If no rule covers the address, the connection fails with 40615 before the login is checked, so this is not a password problem.

Two parts of the message do the diagnosis for you: the server name (myserver) and the client IP address Azure saw (203.0.113.24). That address is your public address after network address translation, which is often different from the one ipconfig shows. Add a rule for that address or range. Microsoft documents a delay of up to five minutes before rule changes take effect.

Common causes

  • Connecting from a network that has never been allowed: a new office, home, VPN, CI runner or cloud VM.
  • A dynamic public IP that changed since the rule was created.
  • A firewall rule written for the private address of the machine instead of its public (NAT) address.
  • A rule added less than five minutes ago, which has not reached the database yet.
  • An Azure service (App Service, Functions, Data Factory) whose outbound addresses are not covered, with "Allow Azure services and resources to access this server" switched off.

Diagnose it

Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.

List the server-level firewall rules

Run in the master database of the logical server, from a connection that is already allowed (or check Networking in the Azure portal).

SELECT name, start_ip_address, end_ip_address, modify_date
FROM sys.firewall_rules
ORDER BY name;
What to look for

Look for a range that contains the IP address in the message. A rule from 0.0.0.0 to 0.0.0.0 (named AllowAllWindowsAzureIps) is the "Allow Azure services" switch.

List the database-level firewall rules

Run in the user database the connection asks for. Database-level rules are checked first and apply only to that database.

SELECT name, start_ip_address, end_ip_address, modify_date
FROM sys.database_firewall_rules
ORDER BY name;
What to look for

A matching range here lets the client into this database even with no server-level rule.

Confirm the address and the name the client really uses

Compare the IP address in the error with the "Add your client IPv4 address" value the Azure portal shows on the server Networking page, which is the address Azure sees. If 40615 appears only on some networks while others connect, check that the server name resolves through normal DNS: Microsoft lists hosts-file or DNS overrides that pin the server to an old gateway address as a cause of 40615 on specific networks.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Add a server-level rule for the address in the portal

Changes configuration

In the Azure portal open the SQL server (not the database), choose Networking, add a firewall rule for the IP address from the message (or select Add your client IPv4 address) and save. Creating rules in the portal needs the SQL Server Contributor or SQL Security Manager role, or ownership of the resource.

Add the rule with T-SQL in master

Changes configuration

From a connection that is already allowed, connected to master as the server admin or the Microsoft Entra admin, create or update a server-level rule. Use a single address where possible.

-- In the master database of the logical server
EXECUTE sp_set_firewall_rule @name = N'Office-Leeds',
     @start_ip_address = '203.0.113.24', @end_ip_address = '203.0.113.24';

Prefer a database-level rule for application access

Changes configuration

Microsoft recommends database-level rules where possible: they open one database instead of all of them. They are created with T-SQL in that database and need CONTROL DATABASE.

-- In the user database
EXECUTE sp_set_database_firewall_rule @name = N'App-Servers',
     @start_ip_address = '198.51.100.10', @end_ip_address = '198.51.100.20';

Allow Azure services, or use a private endpoint

Changes configuration

For Azure-hosted clients with changing outbound addresses, the Allow Azure services and resources to access this server switch creates the 0.0.0.0 rule. A virtual network rule or a private endpoint limits access to your own networks instead.

Caution: Microsoft warns that this switch allows connections from all Azure services, including services in other customers' subscriptions. Rely on logins and permissions as well, or use private endpoints or virtual network rules.

Examples

Connecting from an address with no firewall rule

Shown as documented by Microsoft; not reproduced here, because 40615 is raised only by Azure SQL Database. The server name and address are placeholders.

-- From a command prompt on a laptop whose public address is 203.0.113.24:
-- sqlcmd -S tcp:myserver.database.windows.net,1433 -d Sales -G
Result
Cannot open server 'myserver' requested by the login. Client with IP address '203.0.113.24' is not allowed to access the server. To enable access, use the 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.

A rule was just added but the error continues

Shown as documented by Microsoft; not reproduced. Firewall changes can take up to five minutes to reach the database. Microsoft documents DBCC FLUSHAUTHCACHE, run in the database that needs the update, to refresh the cached rules sooner.

-- In master, from an allowed connection:
EXECUTE sp_set_firewall_rule @name = N'Home', @start_ip_address = '203.0.113.24', @end_ip_address = '203.0.113.24';

-- A new connection from 203.0.113.24 a minute later can still fail with 40615.
Result
Cannot open server 'myserver' requested by the login. Client with IP address '203.0.113.24' is not allowed to access the server. To enable access, use the 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.

How to prevent it

Manage firewall rules as code (Azure CLI, PowerShell or templates) with a name that says who each rule is for, and review them regularly. Use database-level rules for applications and server-level rules for administrators, as Microsoft recommends, and avoid wide ranges.

For production, connect applications through private endpoints or virtual network rules so they do not depend on public addresses at all. For people on dynamic addresses, a VPN with a fixed egress address is easier to allow than chasing each change. See Azure SQL Database for the service overview.

Common questions

Is error 40615 a wrong password?

No. The firewall rejects the connection based on the client IP address. Once a rule allows the address, the login and password are checked as usual and can still fail with error 18456.

Why is the IP address in the message different from my computer address?

Azure sees your public address after network address translation, not the private address of your machine. Create the rule for the address in the message.

Does error 40615 apply to Azure SQL Managed Instance?

No. The server and database IP firewall rules described here belong to Azure SQL Database. Managed Instance access is controlled by its virtual network and network security groups.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 23 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4) message catalogue; Microsoft Learn (Azure SQL Database). Message text checked against the engine's sys.messages catalogue.

Still stuck on a SQL Server error?

Browse the full SQL Server error library, or get hands-on help from an experienced SQL professional.