Using Connection Failover
- Last Updated: April 16, 2026
- 3 minute read
- ADO.NET
- Documentation
Connection failover provides failover protection for new connections only. The data provider fails over new connections to an alternate, or backup, database server if the primary database is unavailable, for example, because of a hardware failure or traffic overload. Alternate servers are tried until a connection is successfully established or until all database servers (primary and alternate) have been tried a specified number of times. If a connection to the database is lost, or dropped, the data provider does not fail over the connection.
For example, as shown in the following figure, Database Server A is designated as the primary database server, Database Server B is the first alternate server, and Database Server C is the second alternate server.
Connection Failover

First, the data provider attempts to connect to the primary database, Database Server A (1). If connection failover is enabled and Database Server A fails to accept the connection, the data provider attempts to connect to Database Server B (2). If that connection attempt also fails, the data provider attempts to connect to Database Server C (3).
In this scenario, it is probable that at least one connection attempt would succeed, but if no connection attempt succeeds, the data provider can retry the primary server and each alternate database for a specified number of attempts. You can specify the number of attempts that are made through the connection retry feature. You can also specify the number of seconds of delay, if any, between attempts through the connection delay feature. See Using Connection Retry for more information about connection retry.
The data provider fails over to the next alternate server only if a successful connection cannot be established with the current alternate server. If the data provider successfully establishes communication with a database and the database rejects the connection request because, for example, the login information is invalid, then the data provider generates an exception and does not try to connect to the next database in the list.
Guidelines for Primary and Alternate Servers
Many databases provide advanced database replication technologies such as DB2 High Availability Disaster Recovery (HADR), Oracle Real Application Clusters (RAC), and Microsoft Cluster Server (MSCS). The failover functionality provided by the data providers does not require any of these technologies, but can work with them to provide comprehensive failover protection. Use the following guidelines for primary and alternate servers to ensure that failover works correctly in your environment:
- Alternate servers should mirror data on the primary server or be part of a configuration where multiple database nodes share the same physical data.
- If using failover with DB2 HADR, the primary server must be the primary server configured in your HADR system and any alternate server must be a standby server configured in your HADR system.
- If using failover with an Oracle RAC, the primary server must be a primary node and any alternate server must be a secondary node.
- If using failover with MSCS, which determines the alternate server for failover instead of the data provider, any alternate server specified must be the same as the primary server. For example:
SQLServerConnection Conn = new SQLServerConnection();
Conn = new SQLServerConnection("Host=Accounting1;Port=1433;Database Name=TEST;User ID=mike;Password=bogey;Alternate Servers="Host=Accounting1;Port=1433;Database Name=TEST");