KNOWNHOST KNOWLEDGE BASE

Hosting Question? Find the Solution - Browse our Guides, Articles, and How-To's

How can I test my migrated website before changing the DNS?

Once our support team migrates hosting accounts from a third-party service provider, you need to update the nameservers. Sometimes, the new hosting provider may lack some features, which might commerce consequences for the website. Best, what if we have a solution to check the website post-migration without updating nameservers or DNS? On every system, you have a hosts file through which you can manually force to request the data from a specific server for a particular domain. Learn, How can I test my migrated website before changing the DNS?


Windows

Windows Hosts file location:

Windows NT/2000/XP/2003/Vista/7/8/10 – C:\windows\System32\Drivers\etc\hosts
Windows 95/98/ME – C:\windows\hosts

1. For this article, we have Windows 10 OS system. First, navigate to C:\Windows\System32\drivers\etc.

navigate-to-hosts-windows-os

2. Right-click on hosts → Edit with preferred file editor (Run as Administrator). You can use windows default NotePad application to edit file instead of going with Notepad ++, which we’ve used for this article.

edit-windows-hosts-files-using-editor

3. Now, enter the domain following the server IP address.

Format:

<IP Address> domainame.com www.domainame.com

Example:

8.8.8.8 kh-demo.com www.kh-demo.com
add-a-record-entry-in-windows-hosts-file

4. Finally, save the file.

test-my-migrated-website-before-changing-the-DNS-windows

5. Windows maintain DNS cache on the system. Next, you need to flush the DNS using Command Prompt (CMD).

DNS Flush Command

ipconfig/flushdns
dns-cache-flushed-windows-os

6. To test the made configuration, use the ping command on command prompt,

Syntax Of Ping Command

ping <IP ADDRESS / DOMAIN>
test-completed-hosts-file-windows-os

You have successfully locally propagated the domain to a server IP address. Now, visit the migrated version of your website by visiting www.example.com or http://example.com in your browser window.


MacOS

In this operation, we need to use the Terminal of MacOS. Let’s get started!

MacOS Hosts file location:

/etc/hosts

1. Open Terminal by navigating to Applications Utilities.

open-terminal

2. You can edit the hosts file using any of the available file editors. In this article, we will use a nano application to edit the hosts file (You will be prompted for your password for sudo access.).

sudo nano /etc/hosts

If it does not exist you can also try

nano /etc/hosts

3. Just as with the Windows steps, you can add additional lines to this file that will point requests for a particular domain to your new server’s IP address.

Format

<IP Address> domainame.com

Example

8.8.8.8 kh-demo.com
add-example-entry-in-etc-hosts-macos

4. Now, type CTRL + X to save the file.

5. MacOS maintain DNS cache on the system. Next, you need to flush the DNS using the following command depending on the MacOS version,

El Capitan (10.11), Sierra (10.12), High Sierra (10.13), Mojave (10.14), and Catalina (10.15)

sudo killall -HUP mDNSResponder

Yosemite (10.10)

sudo discoveryutil udnsflushcaches

Lion (10.7), Mountain Lion (10.8), and Mavericks (10.9)

sudo killall -HUP mDNSResponder

Snow Leopard (10.6)

dscacheutil -flushcache
flush-dns-macos

6. To test the made configuration, use the ping command on terminal,

Syntax Of Ping Command

ping <IP ADDRESS / DOMAIN>
ping-test-macos

Conclusion

Now that we’ve gone over how to test my migrated website before changing the DNS. This article is helpful before updating the nameservers. Once you’re done with testing, remove the entry from the respective hosts file.

KnownHost offers 365 days a year, 24 hours a day, all 7 days of the week best in class technical support. A dedicated team ready to help you with requests should you need our assistance. You’re not using KnownHost for the best webhosting experience? Well, why not? Check with our Sales team to see what can KnownHost do for you in improving your webhosting experience.