If I add multiple A-records for my domain, they are returned in a round robin order by DNS servers.

Example: A example.com A example.com A example.com

But how does web browsers react if the first host ( is down (unreachable)? Do they try the second host ( or do they return a error message to the user? Are there any difference between the most popular browsers?

If I implement my own application, I can implement so that the second is used in case the first is down, so it's possible. And this would be very helpful to create a fault tolerant website.


Yes, most browsers from the last 5-10 years will try the other A records if one fails to respond. This is sometimes called "browser retry" or "client retry" apparently. You'll pretty much only find stuff about it in the context of the various browser exploits which this feature enables against sites not using it (see DNS rebinding and DNS pinning, anti-dns pinning, anti-anti-dns pinning, anti-anti-anti-dns pinning, and so on). Kind of a bad reputation, but it does prove it exists.

Pretty much every browser does indeed receive the full list of A records, and does indeed check others if the one it is using fails. You can expect each client to have a 30 second wait when they first try to access a site when a server is down, until it connects to a working address. The browser will then cache which address is working and continue using that one for future requests unless it also fails, then it will have to search through the list again. So 30 second wait on first request, fine thereafter.

But it isn't something you necessarily want to use, it's going to have lots of caveats about browser compatibility, os compatibility, proxy compatibility, cache-control headers are going to have weird effects on whether it remembers which IPs are down or starts having that 30 second wait on every request, people writing custom clients for your site are going to end up using gethostbyname instead of getaddrinfo and not be able to handle the failover, all sorts of potential problems.

You also can't rely on multiple A records to allow for "master" and "slave" servers, because you'll never know which address a browser is going to pick out of the list. They all need to be just as capable of handling visitors if running, because any one might get traffic if it's up. A browser might think your third server out of the list is the most appealing, maybe it looks the closest, and it will choose that one even though all three are still up.

But if you can live with the limitations and have a reasonably simple HTTP system that you can predict the browser interaction with, it will work.

Oh, you'll also have to deal with a lot of people telling you this doesn't exist (since that was true 15 years ago). But you can try telnet-ing to a domain name with several A records, some with dead IPs and some good ones, if you need to prove it (yes, even good old telnet now uses getaddrinfo and handles multiple A records gracefully these days) -- it will print out a nice list of the IPs it's trying until it finally succeeds.

| improve this answer | |
  • 12
    Here's a report from the National Bureau of Economic Research which supports Joff's answer. – Marco Oct 27 '11 at 15:06
  • 3
    Intriguingly, while stackexchange.com points to one IP, Google returns several: $ dig google.com @ns1.google.com ;; ANSWER SECTION: google.com. 300 IN A google.com. 300 IN A google.com. 300 IN A google.com. 300 IN A google.com. 300 IN A google.com. 300 IN A google.com. 300 IN A google.com. 300 IN A google.com. 300 IN A google.com. 300 IN A google.com. 300 IN A – Louis St-Amour Aug 10 '12 at 19:21
  • 1
    Sorry, but I don't think that's how it works. Browsers have nothing to do with resolving IP addresses -- that happens in system software. If you provide multiple A records, you should assume that any given client will receive a random one from the list. – Jan Steinman Dec 5 '12 at 18:57
  • 21
    This is how it works in contemporary browsers. They all choose to use system calls like getaddrinfo() to get multiple IP addresses and handle failover internally, rather than getting a single IP address from the system. Other commenters and answerers here are part of the "lot of people telling you this doesn't exist" from Joff's last paragraph---I assume they mean well but they are spreading misinformation. – Robert Tupelo-Schneck Sep 17 '13 at 15:14
  • 1
    To support Joff's statement of "browsers 5-10 years ago", here's a test done by the National Bureau of Economic Research which states you get this kind of system working up to IE 8. Sound fair to me. :) – Jomar Sevillejo Sep 21 '16 at 2:43

Be warned that Windows Vista implements the stupid parts of RFC3484 (i.e. the backporting from IPV6 to IPV4) and will prefer the IP address that shares most prefix bits with the user's IP address rather than picking one at random. Since most users have IP addresses that start with 192.168, that means whichever of your IP addresses happens to share most prefix bits with that will get most of the Vista traffic. Microsoft fixed this particular bit of idiocy in Windows 7 and later, so it's not as much of an issue as it used to be.

| improve this answer | |
  • Vista, that's a good one! – Randy L Jul 15 '19 at 14:07

This is basic DNS load balancing distribution technique: DNS Round Robin. This has nothing to do with browser, it depends on the implementation of the resolver , and the local/remote cache of the DNS address. Changes are that if a server fail, due to caching in the DNS layer your website may be inaccessible.

See here for a basic explanation about Round Robin DNS on WikiPedia.

| improve this answer | |
  • 1
    Well, since the browser is the resolver - it depends on the implementation of the browser, as what I know. – Jonas Mar 19 '11 at 23:31
  • 2
    No, there are the system library that resolve the dns using of course the DNS Nameserver that you setup in the system. The function are part of the standard operating system library. – keatch Mar 19 '11 at 23:56
  • But both nslookup cnn.com on Windows and host cnn.com on Linux returns a list of IP-addresses, so then it definitely depends on the implementation of the browser. – Jonas Mar 20 '11 at 0:07
  • 5
    @iivel: No, that is not true. If I write a Java program and resolve a name with InetAddress.getAllByName("example.com") I get a list with all IP-addresses, so I can choose to start a TCP-connection to all of them if I want. And it's the same if you use getaddrinfo() in C. So it's definitely a choice that the developers do and not the Operating System. – Jonas Mar 20 '11 at 8:30
  • 1
    @J.Money This question is asking exactly about the implementation, not how we can do it. – Franklin Yu Feb 27 '18 at 14:42

The OS determines what IP to use, not the browser. Windows will round robin the returned list (in the list passed back from DNS), though will continue to use the same address until DNS is flushed or times out. *ix implementations depend partially on the bundled tcp stack implementation but typically follow a round robin method as well.

| improve this answer | |
  • 2
    No, this is wrong. If I write a Java program and resolve a name with InetAddress.getAllByName("example.com") I get a list with all IP-addresses, so I can choose to start a TCP-connection to all of them if I want. And it's the same if you use getaddrinfo() in C. So it's definitely a choice that the developers do and not the Operating System. The DNS-server only decides in what order the list of IP-addresses is returned. – Jonas Mar 20 '11 at 8:38
  • Ok, so you can manually do whatever you want with the stack - you could even roll your own and forget about winsock all together. However, if you write an app and let the OS do its thing (abstract away) - then the behavior is as noted. You question was specifically about traditional application behavior - not what is possible. Most developers handle using the unresolved name and let the OS do what it does, rather than tightly coupling behaviors together. – iivel Mar 20 '11 at 13:46
  • 1
    Not sure why the answer was downvoted, but the question is about what browsers do. Currently all browsers let the OS do the resolution (short of some plugins for Firefox and Chrome). If you'd like details on how to ensure availability should a provider go down - look at load balancers or clustering. – iivel Mar 20 '11 at 14:11
  • Browsers probably do as you say - let the OS do the DNS lookup, but it return a list with IP-addresses to the Browser. And the question is: What does the most popular browsers do if the first address is unreachable? do they try the second? – Jonas Mar 20 '11 at 14:38
  • 2
    The article you quoted by Pete Tenereillo is known to be outdated (mostly incorrect nowadays). With Chrome, chrome://net-internals/#dns shows current DNS cache. I don't believe OS always determines which IP to use. At least with Chrome you can choose to use AAAA if available or A only. OP is talking about how browsers select from DNS relies, not how the computer find its DNS server.... – sdaffa23fdsf Jul 22 '13 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.