Home / Azure

AzureCheat sheetBeginner

Azure SQL Database connection errors cheat sheet: 40615, 18456, 4060, 47073 and timeouts

Map each Azure SQL Database connection error to its cause, whether firewall, public access, DNS, ports, login or Entra user, and fix it with az CLI, T-SQL and a few quick tests.

Deepak Bhardwaj7 min read

Applies toAzure SQL Database (single databases and elastic pools) on a logical server; public endpoint, service endpoints and private endpoints

When an app or a user can't connect to Azure SQL Database, the error number tells you which layer failed. Read the number first, then go to the matching section below.

Error number to fix

Error / message Layer Usual cause Fix
40615 "Client with IP address 'x' is not allowed to access the server" Server firewall Client IP not in a firewall rule Add an IP rule, or use a private endpoint
40914 "Client is not allowed to access the server" VNet rule Client subnet has the Microsoft.Sql service endpoint but no VNet rule on the server Add a VNet rule for that subnet
47073 "Connection was denied since Deny Public Network Access is set to Yes" Public access Public network access disabled, but the client resolves to the public endpoint Fix private DNS, or connect from a network with the private endpoint
42101 when editing firewall rules Public access You can't change firewall rules while public access is disabled Expected. Use private endpoints, or switch to Selected networks
18456 "Login failed for user 'x'" Authentication Wrong password, a contained user in a different database, or Entra-only authentication enabled See Login failures
18456 "Login failed for user '<token-identified principal>'" Entra ID Token is valid but no user exists in the database CREATE USER ... FROM EXTERNAL PROVIDER
4060 "Cannot open database 'x' requested by the login" Authorization Database name wrong, or no user for this login in that database Check the name and create the user
40532 "Cannot open server 'x' requested by the login" Login format The user@server suffix doesn't match the server you connected to Fix the user name or server name
Timeout, error 26/53/10060, "network-related or instance-specific" Network DNS, port 1433 blocked, or ports 11000-11999 blocked under Redirect See Network checks
40613, 40197, 40501, 49918 Service Transient: reconfiguration, failover or throttling Retry with backoff. Don't change the firewall

Set variables

RG=rg-data; SRV=sql-prod-weu; DB=appdb
FQDN=$SRV.database.windows.net

Firewall and public access

# Is public access on, and what's the minimum TLS version?
az sql server show -g $RG -n $SRV --query "{public:publicNetworkAccess, tls:minimalTlsVersion}" -o table

# Server-level IP rules and VNet rules
az sql server firewall-rule list -g $RG -s $SRV -o table
az sql server vnet-rule list -g $RG -s $SRV -o table

# Add one client IP (40615)
az sql server firewall-rule create -g $RG -s $SRV -n allow-ops-vpn \
  --start-ip-address 203.0.113.10 --end-ip-address 203.0.113.10

# Add a subnet that uses the Microsoft.Sql service endpoint (40914)
az sql server vnet-rule create -g $RG -s $SRV -n allow-app-subnet \
  --vnet-name vnet-app --subnet snet-app

The IP in the 40615 message is the address Azure SQL saw. Behind NAT, a firewall or a proxy, that is the egress IP, not the client's own address. Allow the IP from the message.

The rule named AllowAllWindowsAzureIps (0.0.0.0 to 0.0.0.0) is the "Allow Azure services and resources to access this server" switch. It admits traffic from any Azure subscription, not only yours.

Warning

Don't fix a 40615 in production by adding 0.0.0.0 to 255.255.255.255 or by turning on "Allow Azure services". That opens the server to the whole internet or to all of Azure. Add the specific egress IP or subnet, or use a private endpoint.

Database-level firewall rules live inside the database and are checked first. Use T-SQL to see them:

-- In master: server-level rules
SELECT name, start_ip_address, end_ip_address FROM sys.firewall_rules;
-- In the user database: database-level rules
SELECT name, start_ip_address, end_ip_address FROM sys.database_firewall_rules;

Firewall changes can take a few minutes to apply, so wait before you decide a new rule didn't work.

Network checks

# Windows client: DNS and port
Resolve-DnsName sql-prod-weu.database.windows.net
Test-NetConnection sql-prod-weu.database.windows.net -Port 1433
# Linux client
nslookup $FQDN
nc -vz $FQDN 1433

# Connection policy: Default, Proxy or Redirect
az sql server conn-policy show -g $RG -s $SRV
Check Healthy result If not
DNS with a private endpoint CNAME to <server>.privatelink.database.windows.net and a private IP Private DNS zone not linked to the client VNet, or on-premises DNS not forwarding. Leads to 47073
Port 1433 TcpTestSucceeded : True NSG, Azure Firewall or the corporate proxy is blocking outbound 1433
Redirect policy (the default for connections from inside Azure) Login works, then queries work Login reaches the gateway on 1433, then the client is redirected to the database node on 11000-11999. Allow that range outbound to the Sql service tag for the region

Connections through a private endpoint use only port 1433 to the private IP, so you don't need the 11000-11999 range there.

Tip

"Login works from my laptop but times out from the VM" is almost always the Redirect port range. Laptops outside Azure use Proxy (1433 only), while Azure VMs default to Redirect.

Login failures (18456 and 4060)

Test with sqlcmd (go-sqlcmd) so the app's connection string isn't a factor:

# SQL authentication: always name the database
sqlcmd -S tcp:$FQDN,1433 -d $DB -U appuser -N -Q "SELECT DB_NAME(), SUSER_SNAME();"

# Entra ID using the signed-in az CLI / environment / managed identity chain
sqlcmd -S tcp:$FQDN,1433 -d $DB --authentication-method ActiveDirectoryDefault -Q "SELECT SUSER_SNAME();"

Common causes:

  • Contained database user, no database in the connection string. The client connects to master, where the user doesn't exist, and gets 18456 or 4060. Add Database=appdb (-d in sqlcmd).
  • Entra-only authentication is on. SQL logins are refused. Check it and use an Entra identity instead:
az sql server ad-only-auth get -g $RG -n $SRV
az sql server ad-admin list -g $RG -s $SRV -o table
  • Token-identified principal. The identity got a token, but nobody created it in the database. As the Entra admin, connected to the user database, run:
CREATE USER [app-orders-mi] FROM EXTERNAL PROVIDER;   -- managed identity or app display name
ALTER ROLE db_datareader ADD MEMBER [app-orders-mi];
ALTER ROLE db_datawriter ADD MEMBER [app-orders-mi];
  • Password just rotated. One app instance or a Key Vault reference is still holding the old secret. Restart or refresh the app after you confirm the new password works with sqlcmd.

Caution

Don't reset the server admin password to fix an app's 18456. Other jobs and tools may use that login, and they will start failing too. Give each app its own database user, or better, a managed identity.

Find failed and blocked connections

Built-in metrics show whether failures are firewall blocks or login errors:

DBID=$(az sql db show -g $RG -s $SRV -n $DB --query id -o tsv)
az monitor metrics list --resource $DBID \
  --metric connection_failed blocked_by_firewall connection_successful \
  --interval PT5M --aggregation Total --offset 2h -o table

If auditing sends to Log Analytics, the failed logins show up with the caller's IP:

AzureDiagnostics
| where Category == "SQLSecurityAuditEvents"
| where action_name_s == "DATABASE AUTHENTICATION FAILED"
| summarize failures = count() by client_ip_s, server_principal_name_s, bin(TimeGenerated, 15m)
| order by failures desc

Column names follow the AzureDiagnostics schema and may differ if you send audit logs to a resource-specific table. Check your workspace's schema.

Prevent it next time

  • Prefer private endpoints with a linked privatelink.database.windows.net zone, and test DNS from every client network, on-premises included.
  • Allow outbound 1433 and 11000-11999 to the Sql service tag in NSGs and Azure Firewall for Azure-hosted clients that use the public endpoint.
  • Use managed identities and contained Entra users instead of shared SQL logins, and always set the database in connection strings.
  • Build retry with exponential backoff into every client, so 40613 and 40197 during failovers don't become incidents.
  • Manage firewall rules as code, and alert on spikes in blocked_by_firewall and connection_failed.