Testing a new website BEFORE changing DNS

Many developers have found themselves in this position before – you’re building a website for a client who is switching to a new host. The idea is the install the new site on the new server, than change the nameservers in DNS and VOILA! In 12-48 hours most people in ...
Arp Laszlo
Search Engine Optimization (SEO)

Many developers have found themselves in this position before – you’re building a website for a client who is switching to a new host. The idea is the install the new site on the new server, than change the nameservers in DNS and VOILA! In 12-48 hours most people in the world will be directed to the new site when they try browsing to it.
The problem, then is how to install a site on the new server and make sure it’s working properly BEFORE editing the domain nameservers. Thankfully, this is a very easy thing to do, thanks to the HOSTS file found in Windows, OS X & Linux.
What is the HOSTS file?
The HOSTS file is used in an operating system to map hostnames to IP addresses. (Wikipedia)
Hostname is another word for domain name. A domain name combined with a top level domain (meaning .com or .org, etc) is what people enter into a browser to access a website – like www.echoleaf.com
HOSTS files can be used to trick a computer into thinking that a website is located at a different IP address than it really is. Viruses and malware sometimes target the HOSTS file to redirect victims to a site that looks like a legitimate site but in reality is not. For example, they can try redirecting a victim to a fake Paypal or bank site to capture login information. They also hope that the victim does not check the url because it will be a dead giveaway that the site is not real. These urls are often long with lots of random letters and numbers after a legit-sounding beginning, like www.paypal.com.34534534.com/3987fh78ch7ygy7fg876sdf76
Editing the HOSTS file to point a domain to different IP address on your computer
Web developers can use this ability of the HOSTS files to trick their computer into thinking that a client’s website is located at a new IP address – the one of the new server. The process goes like this:

  1. Find the IP address for the new hosting account or server.
  2. Find the HOSTS file
  • Windows
    • Go to C:\windows\system32\drivers\etc\ or %systemroot%\system32\drivers\etc\
    • In Windows XP, you can just double-click and start editing the file.
    • In Windows Vista or 7, click Start – search for Notepad, right-click and select Run as Administrator. From the Notepad file menu, open the HOSTS file, then start editing.
    • Saving: from the Notepad file menu, select Save.
  • OS X
    • Open Terminal
    • In Terminal, type in sudo nano /private/etc/hosts and hit Enter.
    • Enter your password as requested
    • Editing is done in the Terminal window, you can use arrow keys to navigate to the bottom of the file and add a new line.
    • Saving: Hit control-O to save the file.
  • Linux

Add a new line mapping the client’s domain to its new IP address. The format is like this: xxx.xxx.xxx.xxx www.domain.com

  • This line goes beneath all the other entries.  Make sure that line does not start with # as that will comment out the line and make it invisible to the operating system.
  • After editing, save the HOSTS file as noted above.

Last step: clear the local DNS cache. This must not be overlooked – if you do not clear the local DNS cache, your browsers will still think the website is located at the old IP address!

  • Windows
    • Click the Start button in lower left, select Run, then type cmd and hit Enter.
    • At the command prompt, type ipconfig /flushdns and hit Enter
    • Done!
  • OS X (10.5+)
    • Open Terminal
    • In Terminal, type in dscacheutil -flushcache and hit Enter
    • Done!

Now when you enter the client’s domain into your browser, you will see it at the new IP address. You can install, configure & test BEFORE editing the DNS nameservers. Keep in mind that this applies ONLY to the one computer whose HOSTS file was edited. If you have 2 computers, you can edit the HOSTS file on one and use the other computer to check the old website located on the old server.
Hope this helps!

Linkbuilding is Dead Durham NC SEO Company

Linkbuilding is Dead – Hallelujah!

The Birth of PageRank: A System Designed to Be Gamed When Google created PageRank and decided that incoming links indicated a webpage’s value, it set ...
Arp Laszlo
SEO Key Performance Indicators for Maximizing Revenue & Organic Traffic

SEO Key Performance Indicators for Maximizing Revenue & Organic Traffic

In today’s ever-evolving digital landscape, achieving and measuring SEO success is paramount. SEO (Search Engine Optimization) is a multifaceted discipline that demands vigilant monitoring of ...
Arp Laszlo
Optimizing Website Homepages for Businesses

Optimizing Website Homepages for Businesses

Do you feel like your website can be doing more for your business? Do you want more people to visit your website, learn about your ...
Arp Laszlo

Check out our Search Engine Optimization Services page for details on how we can get you more organic traffic, more leads, and more conversions.

Learn about our SEO services

Why Work With Me?

Unlike big agencies that offer cookie-cutter solutions, I provide personalized, hands-on service that fits your specific needs.

Tailored for Small Businesses – I focus on what works for YOU, not just industry trends.

No Middlemen, No Bureaucracy – You work directly with me, so you get fast, personal support.

Proven Strategies That Get Results – I don’t just “do marketing” or “build websites”—I create solutions that drive revenue.

Ready to take your business to the next level?
Let’s talk!
Schedule a free consultation