Why do I get ‘host not found’ errors? Well…
A friend asked me today if I know about DNS Servers. “Yeah, I do. Can I help with something” I wrote back? She wrote this:
For example, in my browser I can type in www.espn.com and when the DNS server does not work, an error message states that the web site could not be found. If I hit refresh on my browser, the web site then loads as normal. This happens randomly. Sometimes the web site loads as normal, sometimes it does not load. Hitting the refresh button one or more times fixes the problem.
She asked it well and I was pleased to read such a clear question. Here’s what I wrote back and maybe it’ll help you understand this problem too:
When you put a URL in your browser, this happens:
- browser asks computer to connect to www.host.com
- computer asks local DNS server for the IP address of www.host.com
- if the local DNS server has that IP cached it responds immediately (hundredths of a second) but if not, it has to ask other DNS servers and the answer to your computer may be delayed by tenths of a second, possible even seconds.
- local DNS server sends the IP address to your computer
- your computer opens a connection to that IP address on port 80 (HTTP, 443 for HTTPS)
- your computer reports to the browser that it’s ready
- your browser sends a request over the connection (GET / HTTP/1.0) to the web server
- the web server sends an answer to your browser over the same connection
- that answer likely contains a large number of other URLs, for images, CSS style sheets, external Javascript files, etc., requiring this cycle be repeated many times for each page.
If the DNS server’s delays too long in responding to your computer’s request for an IP address lookup, your browser will tell you that, albeit in code, by showing you the “host not found” page.
So, there you are. The next question is probably going to be why would there be delays in getting an answer from the DNS server? Ahhh… well….
Best,
Mike