Troubleshoot connection issues to Azure SQL Database
When the connection to Azure SQL Database fails, you receive error messages. This article is a centralized topic that helps you troubleshoot Azure SQL Database connectivity issues. It introduces the common causes of connection issues, recommends a troubleshooting tool that helps you identity the problem, and provides troubleshooting steps to solve transient errors and persistent or non-transient errors.
If you encounter the connection issues, try the troubleshoot steps that are described in this article.
If your Azure issue is not addressed in this article, visit the Azure forums on MSDN and Stack Overflow. You can post your issue in these forums, or post to @AzureSupport on Twitter. You also can submit an Azure support request. To submit a support request, on the Azure support page, select Get support.
Connection problems may be caused by any of the following:
- Failure to apply best practices and design guidelines during the application design process. See SQL Database Development Overview to get started.
- Azure SQL Database reconfiguration
- Firewall settings
- Connection time-out
- Incorrect login information
- Maximum limit reached on some Azure SQL Database resources
Generally, connection issues to Azure SQL Database can be classified as follows:
- Transient errors (short-lived or intermittent)
- Persistent or non-transient errors (errors that regularly recur)
Try the troubleshooter for Azure SQL Database connectivity issues
If you encounter a specific connection error, try this tool, which will help you quickly identity and resolve your problem.
Troubleshoot transient errors
When an application connects to an Azure SQL database, you receive the following error message:
Error code 40613: "Database <x> on server <y> is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of <z>"
This error message is typically transient (short-lived).
This error occurs when the database is being moved (or reconfigured) and your application loses its connection to the database. Database reconfiguration events occur because of a planned event (for example, a software upgrade) or an unplanned event (for example, a process crash, or load balancing). Most reconfiguration events are generally short-lived and should be completed in less than 60 seconds at most. However, these events can occasionally take longer to finish, such as when a large transaction causes a long-running recovery.
Steps to resolve transient connectivity issues
- Check the Microsoft Azure Service Dashboard for any known outages that occurred during the time during which the errors were reported by the application.
- Applications that connect to a cloud service such as Azure SQL Database should expect periodic reconfiguration events and implement retry logic to handle these errors instead of surfacing these as application errors to users. Review the Transient errors section and the best practices and design guidelines at SQL Database Development Overview for more information and general retry strategies. Then, see code samples at Connection Libraries for SQL Database and SQL Server for specifics.
- As a database approaches its resource limits, it can seem to be a transient connectivity issue. See Resource limits.
- If connectivity problems continue, or if the duration for which your application encounters the error exceeds 60 seconds or if you see multiple occurrences of the error in a given day, file an Azure support request by selecting Get Support on the Azure Support site.
Troubleshoot persistent errors
If the application persistently fails to connect to Azure SQL Database, it usually indicates an issue with one of the following:
- Firewall configuration. The Azure SQL database or client-side firewall is blocking connections to Azure SQL Database.
- Network reconfiguration on the client side: for example, a new IP address or a proxy server.
- User error: for example, mistyped connection parameters, such as the server name in the connection string.
Steps to resolve persistent connectivity issues
- Set up firewall rules to allow the client IP address. For temporary testing purposes, set up a firewall rule using 0.0.0.0 as the starting IP address range and using 255.255.255.255 as the ending IP address range. This will open the server to all IP addresses. If this resolves your connectivity issue, remove this rule and create a firewall rule for an appropriately limited IP address or address range.
- On all firewalls between the client and the Internet, make sure that port 1433 is open for outbound connections. Review Configure the Windows Firewall to Allow SQL Server Access and Hybrid Identity Required Ports and Protocols for additional pointers related to additional ports that you need to open for Azure Active Directory authentication.
- Verify your connection string and other connection settings. See the Connection String section in the connectivity issues topic.
- Check service health in the dashboard. If you think there’s a regional outage, see Recover from an outage for steps to recover to a new region.
- Search the documentation on Microsoft Azure
- View the latest updates to the Azure SQL Database service