Skip to content

Est. 2011ยทMicrosoft Partner ID 7033487ยทDelivery under 3 minยทSupport 7 days a week

Your vault is empty.

License Error 40615

Error 40615 and 40613: Azure SQL Firewall Blocks and Unavailable Databases

12 min read Updated October 5, 2026 SQL Server

Fix it now

Both codes come from the Azure SQL gateway and mean opposite things. 40615 says your client address is not on the firewall list, so the connection never reached a database. 40613 says the firewall was satisfied and the database is not available yet, which Microsoft documents as a transient fault to retry.

Run these from the client that is failing, in PowerShell

nslookup yourserver.database.windows.net
Test-NetConnection yourserver.database.windows.net -Port 1433
  1. Read which code you have. 40615 names your client IP address; 40613 names the database and gives a session tracing ID.
  2. For 40615, open the logical server in the Azure portal, go to Networking, and add a firewall rule for the address in the message. The portal offers to add your current client address.
  3. For 40613, retry with exponential backoff. Microsoft’s guidance is 5 to 60 seconds, and most reconfiguration events finish inside 60 seconds.
  4. If nslookup returns an address that does not belong to the current Azure SQL gateway range for your region, you have a DNS override rather than a firewall problem. Remove the hosts file entry, static CNAME or private DNS mapping and flush the caches.
  5. If the connection policy is Redirect, confirm the client can also reach TCP 11000 to 11999 outbound, not just 1433.

Firewall rules can be scripted in T-SQL instead. sp_set_firewall_rule runs in the master database of the logical server; sp_set_database_firewall_rule runs inside the individual database.

If you are connecting now you can stop here. If not, the next section explains what the gateway decides and in what order.

Why it happens

A connection to Azure SQL does not go straight to a database. It arrives at a regional gateway, which decides whether the connection is allowed and where to send it. The firewall check happens there, against server-level rules stored in the logical server’s master database and, optionally, database-level rules stored inside individual databases. A connection matching no rule is turned away with 40615 and never reaches an engine.

Once past the firewall, the gateway has to route the connection to whichever node currently hosts your database. If the database is being moved, upgraded, recovered, scaled, or resumed from a serverless pause, there is nowhere to send it and the answer is 40613: the database is not currently available, please retry the connection later, with a session tracing ID for support. Microsoft classes this as a transient fault, and the documented response is retry logic rather than a configuration change.

How the connection is routed after that matters more than most people expect. The connection policy has three settings. Redirect gives the client the address of the node and needs outbound TCP 1433 to the gateway plus TCP 11000 to 11999 to the regional Azure SQL addresses. Proxy sends everything through the gateway and needs only 1433. Default picks Redirect for clients inside Azure and Proxy for clients outside it, which is why a workload behaves differently after it moves into Azure.

The client address is not on the firewall list

You have this one if 40615, with an address in the message that you either do not recognise or that has changed since you last connected.

  1. In the Azure portal, open the logical server, choose Networking, and add a rule covering the address shown.
  2. For a home or mobile connection with a dynamic address, expect it to recur. Add the range your provider uses, or connect through a VPN with a stable egress address.
  3. For scripting, use sp_set_firewall_rule in the master database, and read back the result from sys.firewall_rules.
  4. Prefer database-level rules where you can. Microsoft’s stated recommendation is database-level rules wherever possible, with server-level rules for administrators and for databases that share access requirements.

Database-level rules can only be created and managed in T-SQL, and only after a server-level rule already exists. Each level caps at 256 rules.

The database is genuinely not available yet

You have this one if 40613, returning within seconds, and the portal shows the database mid-operation, restoring, or in a serverless tier resuming from a pause.

  1. Retry with exponential backoff rather than in a tight loop. Every supported client library has a retry policy for exactly this.
  2. For serverless databases, expect a delay on the first connection after an auto-pause. Increase the auto-pause delay if that is disruptive, or move to a provisioned tier.
  3. If it persists beyond 60 seconds, stop retrying and open a support case with the session tracing ID from the message.

Microsoft names a second cause of 40613 that is easy to miss: a dedicated administrator connection is already established to that database, and only one is allowed.

DNS is pointing the client at a stale gateway address

You have this one if 40615, 40532 or 18456 persistently, from one client network only, while the service itself is healthy and other networks connect.

  1. Run nslookup yourserver.database.windows.net and check the answer against the current gateway addresses for your region.
  2. Remove hosts file entries, static CNAME records and private DNS zone mappings that pin the FQDN to an address.
  3. Flush DNS caches on the client and on any intermediate resolver, then retry.

Never pin an Azure SQL FQDN to a specific IP address. Gateway addresses change, and the failure this produces looks exactly like a firewall or a login problem.

The blocking is outbound rather than inbound

You have this one if The firewall rule is definitely correct, and the connection still never arrives.

  1. Confirm outbound TCP 1433 is permitted from the client network. Many corporate networks block it by default.
  2. Check the server’s connection policy. In Redirect mode, clients also need outbound access on TCP 11000 to 11999 to the regional Azure SQL addresses.
  3. If you use a dedicated administrator connection, open TCP 1434 and 14000 to 14999 as well.
  4. If outbound access cannot be widened, use a private endpoint and reach the server over your own network instead of the public gateway.

You are meeting a resource limit, not a firewall

You have this one if 10928 or 40501 under load, with connections succeeding at quieter times.

  1. For 10928 with Resource ID 1, you have reached the worker limit. Look for blocking chains and highly parallel queries before scaling.
  2. Read recent consumption: SELECT start_time, end_time, database_name, sku, max_worker_percent FROM sys.resource_stats;
  3. For 40501, back off for 10 seconds as the message instructs, then retry.
  4. Pool connections properly instead of opening one per operation, and only then consider a larger service objective.

Full reference

Telling the six codes apart

Code What the service is saying Your move
40615 Your client address is not permitted by the server firewall Add a rule, or connect through a private endpoint
40613 The database is not currently available; retry later, session tracing ID supplied Retry with backoff for up to 60 seconds, then raise a case
40532 Login failed at the gateway Check DNS resolution and the fully qualified server name before touching credentials
40197 The service has encountered an error processing your request; error code %d Transient. Log the embedded code (40020, 40143, 40166, 40540) and retry
10928 Resource ID: 1. The limit for the database is %d and has been reached Worker limit. Resolve blocking and parallelism before scaling up
40501 The service is currently busy. Retry the request after 10 seconds Engine throttling. Back off and review resource consumption

The 0.0.0.0 rule, and what it actually admits

Turning on “Allow Azure services and resources to access this server” creates an inbound firewall rule named AllowAllWindowsAzureIps with a start and end address of 0.0.0.0. It is not a rule for a real client, and it is much broader than the name suggests. Microsoft’s warning is direct: it allows connections from all Azure services, including services running in other customers’ subscriptions, and it does not restrict access to your subscription or resource group.

Two further points that cost people time. The toggle does not cover traffic arriving from your own virtual network through a private endpoint, so an explicit rule is still needed there. And Microsoft’s recommendation for anything sensitive is a virtual network service endpoint or a private endpoint rather than this rule at all.

Ports, by connection policy

Policy Outbound ports the client needs Where it applies
Redirect TCP 1433 to the gateway addresses, plus TCP 11000-11999 to all Azure SQL addresses in the region Recommended; lowest latency
Proxy TCP 1433 to the gateway addresses only Higher latency; the only option on locked-down networks
Default Redirect for clients inside Azure, Proxy for clients outside What you get if nobody chose
Dedicated administrator connection TCP 1434 and 14000-14999 Needed only if you use the DAC

Rules at two levels

Server-level Database-level
Scope Every database on the logical server One named database
Stored in The master database of the logical server The individual database
Managed with Portal, PowerShell, T-SQL or REST T-SQL only, and only after a server-level rule exists
Read back from sys.firewall_rules in master sys.database_firewall_rules in the database
Maximum 256 per server 256 per database

Microsoft’s recommendation is to use database-level rules wherever possible, because they are tighter and they travel with the database. Server-level rules are for administrators, and for the case where many databases genuinely share one access requirement.

Retry, and what it should look like

  • 40613, 40197 and 40501 are all documented as transient. Handle them in code, not by hand.
  • Use exponential backoff in the 5 to 60 second range. Microsoft states that most reconfiguration events complete within 60 seconds.
  • Log the embedded error code from a 40197 message. It distinguishes 40020, 40143, 40166 and 40540, and support will ask for it.
  • Keep the session tracing ID from a 40613. It is the identifier a case will be worked from.
  • Do not retry a 40615. A firewall rule will not appear because you asked twice.

When a licence is the actual fix

If your fix is a firewall rule, it costs nothing and you should not be buying anything. The licensing question only arises further along, when you work through this and conclude that a platform service is the wrong home for the workload because you need control of the network path, the patching window or the version. Running SQL Server yourself needs a licence, and Arco supplies SQL Server 2025 Standard in two-core packs. Core licensing is sold per core with a minimum per instance that depends on the shape of the server, so tell us what you have in mind and we will work out what it needs. Staying on Azure SQL and adding the rule is an equally good answer, and much the cheaper one.

Every code this article covers

Code What it points at Source
40615 Cannot connect to the server: the client IP address is not permitted by the server’s firewall rules Microsoft Learn
40613 Database on server is not currently available; retry the connection later. Transient, and the message carries a session tracing ID Microsoft Learn
40532 Login failed at the gateway. Microsoft groups it with 18456 and 40615 as a persistent login failure, and documents stale DNS entries for the server FQDN as a cause Microsoft Learn
40197 The service has encountered an error processing your request. Please try again. Error code %d. Transient, with the embedded code naming the failure Microsoft Learn
10928 Resource ID: 1. The limit for the database is %d and has been reached. Resource ID 1 is the worker limit Microsoft Learn
40501 The service is currently busy. Retry the request after 10 seconds. Engine throttling with an incident ID Microsoft Learn

Confirm the fix worked

  1. Connect from the client that failed and confirm the connection succeeds without the portal open.
  2. Confirm the address the server sees matches the rule you added: read sys.firewall_rules in master.
  3. Run a query and confirm it returns, so you know you passed both the firewall and the routing stage.
  4. Leave the connection idle long enough for a serverless database to pause, then reconnect and confirm your retry logic copes.
  5. If you removed a DNS override, confirm nslookup now returns a current gateway address for the region.

Questions people ask about this

Why does 40615 come back every few days?

Because your client address changed. Home and mobile connections are usually dynamic, and large offices egress from more than one address. Add the range rather than the single address, or connect through something with a stable egress.

Should I just allow all addresses?

No. A rule spanning the internet exposes the server to anyone who learns its name, and the name is not a secret. Note that the AllowAllWindowsAzureIps rule is broader than it sounds too: Microsoft warns it admits Azure resources belonging to other customers’ subscriptions.

Is 40613 something I have done wrong?

Almost never. It is the platform saying the database is not ready, usually for seconds. Handle it with retry and backoff, and treat it as an incident only once it passes 60 seconds, which is where Microsoft’s own guidance stops recommending retry.

My firewall rule is right and I still cannot connect. What now?

Check outbound first. If the connection policy is Redirect, the client needs TCP 11000 to 11999 outbound as well as 1433. Then check DNS: a hosts file entry or private DNS zone pinning the server name to an old gateway address produces persistent login failures that look like a firewall problem.

Would moving to SQL Server on a VM avoid these errors?

It would replace them with different ones. You gain control of the network path and lose managed patching, backups and failover, and you need a licence and someone to run it. Do not make that trade to avoid a firewall rule.

Related error codes

Was this article helpful?

Your feedback helps us improve our documentation.

Related articles

Free Fix Error 9002: The Transaction Log Is Full – Find the log_reuse_wait Reason Free Fix Error 53 and Error 26: SQL Server Instance Not Found on the Network Free Fix SQL Server Error 18456: Read the State Number to Find the Real Cause Free Fix Error 7202: Linked Server Missing From sys.servers and Ad Hoc Query Blocks
โ† Back to Knowledge Base