Networking & DNS

DNS failover between servers or clouds explained

How DNS failover works with health checks and low TTLs, how it compares with floating IPs and load balancers, setting it up across two servers or providers, and its limits.

IntermediateWebsites and servers2 min read

When your servers are in different data centres or with different providers, a shared floating IP is not possible. DNS failover solves this by changing which IP a hostname points to when a health check detects that the primary server is down.

Before you start

  • Two servers able to serve the same site or service, with data kept in sync (database replication, file sync).
  • A DNS provider that offers health checks and failover records, or a monitoring tool that can update DNS by API.
  • Background: high availability basics.

How DNS failover works

  1. The DNS provider checks the primary server (HTTP, HTTPS or TCP) every few seconds or minutes from several locations.
  2. While healthy, the record (e.g. www) returns the primary IP.
  3. After a set number of failed checks, the provider returns the secondary IP instead.
  4. When the primary recovers, records switch back (automatically or manually).

TTL matters

Resolvers cache answers for the record's TTL. Use a low TTL such as 60–300 seconds on failover records, so clients pick up the change quickly. Some resolvers and browsers cache longer, so a small share of users may hit the dead server for a while.

Set it up

  1. Prepare the standby server and confirm it can serve traffic on its own IP (test with a hosts file entry).
  2. In your DNS provider, create a health check for the primary (e.g. https://203.0.113.10/health with the right Host header).
  3. Create failover records: primary pointing to 203.0.113.10, secondary to 198.51.100.20, linked to the health check.
  4. Lower TTL and add alerts so you know when failover happens.
  5. Test by stopping the web server on the primary and watching resolution with dig +short www.example.com.

Compared with other approaches

DNS failoverFloating IPLoad balancer
Across providers/regionsYesNo (same L2 network)Global LBs only
Switch timeSeconds to minutes plus cachingSecondsSeconds
ComplexityLowMediumMedium–high

For same-network failover see keepalived floating IP.

Limits and pitfalls

  • Data consistency is your job: if the standby has stale data, users see old content or lose writes.
  • Email (MX) failover works differently; MX records already support priorities.
  • Health checks must test something meaningful (an endpoint that checks the database), not just that port 80 is open.

Frequently asked questions

Can I do active-active with DNS?

Yes, by returning multiple A records or using geo/latency routing, combined with health checks.

Does Cloudflare proxying change this?

When proxied, the CDN connects to your origins and can use its own load balancing features; see Cloudflare with cPanel.

Is DNS failover enough for a small site?

Often, good backups and quick restore are simpler. Failover makes sense when downtime is costly.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.