Setting up a new domain name or changing where it points can be one of the most confusing aspects of configuring a new site for less experienced web masters. The most common question asked of web hosting companies’ support teams is: “Why is my domain name not working.” They’ve followed the instructions carefully, changed the records at their domain registrar so it’s using the right domain name servers, and yet, when they or other users try to visit the site by entering the domain name into their browser address bar, they get an error page.
Understanding why this happens requires a basic knowledge of how DNS works. The Domain Name System converts human readable web addresses like “www.example.com” into a set of machine readable numbers called an IP address that looks like this: “255.255.255.255”, or like this:“3ffe:1900:4545:3:200:f8ff:fe21:67cf”. It’s similar to how, in the old days, people used to look up phone numbers; they knew the name of the person they wanted to call and used that to find the number in the alphabetical list of a phone book.
DNS is a bit more complicated. When you enter the web address into your browser’s address bar a number of things happen very quickly.
First a bit about caches. A cache is simply a store of information. Caches hold onto data that’s already been fetched from other servers because it’s quicker than fetching it every time. Your browser has a DNS cache and so does your operating system. When you enter the web address, the browser looks to see whether it already has the mapping from address to IP in its cache; if it doesn’t it hands the request off to the operating system to see if it knows.
If neither of them know, the request is forwarded to the DNS servers of the Internet Service Provider being used to link the browser to the Internet. If that server doesn’t have the information in its cache, then it starts to question other DNS servers on the Internet in a specific order.
Consider “www.example.com”; it can be broken down into a top-level domain (TLD), the “.com” part; a domain, the “example” part; and a subdomain, “www” (the subdomain isn’t important for what we’re discussing here). There’s also an invisible component known as the root domain — imagine an extra dot on the end with nothing after it. The ISP’s DNS server is called a recursive server; when it doesn’t have the data in its cache, it first asks the DNS server responsible for overseeing the root domain where it can find the DNS server responsible for the “.com” top-level domain. Then it asks the “.com” DNS server where it can find information about the “example” domain. The server with this knowledge is called the authoritative server for “example.com”: it knows the IP address.
You might be asking what all this has to do with the domain name of your new site not working: it’s because of the caches. Every domain name has an associated Time To Live (TTL) record. It’s often 4 hours (14,400 seconds). That’s to tell the DNS servers how long they should hold the information relating to the domain in their cache. After 4 hours, the DNS server will “forget” the mapping of URL to IP, but before then, when it gets a request for a domain, it answers from its cache instead of asking the authoritative name server. The information it has could be up to 4 hours old, and if you’ve changed where the domain name points in the meantime, your browser will be sent to the wrong place.
I imagine that right now you’re thinking “Alright, 4 hours isn’t so long.” Unfortunately, sometimes the people running very busy DNS servers want to save them a bit of work, and so they will ignore a TTL if it’s shorter than 24 hours and occasionally 48 hours. So, in some rare cases, it will take up to 48 hours for your DNS records to propagate through the system and for your domain name to work properly for everyone.
While it can be frustrating to wait for your domain to work, the DNS is a complex system of recursive caching servers. You’ll need to be patient, but it should start working within 48 hours and probably less. If it doesn’t there may be a problem with the configuration at your domain registrar.
Also published on Medium.