# How To Test Or Preview Your Website Before Switching DNS

> One of the most common questions we get is, “How Do I Preview My Website Before Changing My Name Servers?” Since we offer free migrations from other web

- Author: [Ryan Gray](https://www.namehero.com/blog/author/ryan-gray/)
- Published: 2016-05-24
- Updated: 2023-06-09
- Category: [DNS Managment](https://www.namehero.com/blog/category/dns-management/), [Website Development](https://www.namehero.com/blog/category/website-development/)
- Web page: https://www.namehero.com/blog/test-preview-website-switching-dns/

One of the most common questions we get is, **“How Do I Preview My Website Before Changing My Name Servers?” **

Since we offer free migrations from other web hosts, a lot of our customers want to double check everything before going live just to ensure there is no downtime and visitors don’t even realize a migration has happened.

Here in the office, our techs actually do this after completing a migration. Since we use a collection of Macbooks and Mac Pros, it’s very simple to test your website before switching DNS.

**If you’re using a Mac:**

1.First, you need your **new IP address**. This can easily be found right inside your welcome email: ![Temporary IP NameHero](https://www.namehero.com/blog/wp-content/uploads/2016/05/Screenshot-2016-05-24-11.03.17.png)

2. Once you have that, open **Terminal** inside of your **Utilities Folder** *(Applications -> Utilities -> Terminal)*

3. To be on the safe side, you should backup your existing host file, just incase. Simply copy/paste the following command and hit return:

**sudo cp /private/etc/hosts /private/etc/hosts-orig**

4. After you have a backup copy, you can then edit your host file. To get started, simply copy/paste the following command and hit return:

**sudo nano /private/etc/hosts**

5. You will then be prompted your admin password for your Mac user. **Enter it** just like you’re logging onto your computer and press **return**.

6. This will bring up your *host file* which looks something like this:

**Host Database## localhost is used to configure the loopback interface# when the system is booting. Do not change this entry.##127.0.0.1 localhost255.255.255.255 broadcasthost::1 localhost**

Below this, you will add your domain and IP address. For example:

** Host Database## localhost is used to configure the loopback interface# when the system is booting. Do not change this entry.##127.0.0.1 localhost255.255.255.255 broadcasthost::1 localhost64.91.237.213 yourcooldomain.com64.91.237.213 www.yourcooldomain.com**

7. After you add your IP + domain press **Control + X** to exit nano and **Y** and **press return** to commit the changes.

8. Once this has been completed, you need to flush your local DNS by typing this command and pressing return:

**dscacheutil -flushcache**

After you do that, close out your open browsers, and re-open to view your website on the new server! Sometimes, just to double check, I’ll upload an unique file to the new server and make sure I can access it in my browser.

**If you’re using Windows:**

1.Locate the hosts file on your computer. Typically, for Windows 10 / 8 / 7 it’s located:

**C:\Windows\System32\drivers\etc**

2. **Right-click** on it and select Notepad.

But sometimes, even when you are logged on with administrative credentials, you may receive the following error message:

**Access to C:\Windows\System32\drivers\etc\ hosts was denied**

Or

**Cannot create the C:\Windows\System32\drivers\etc\hosts file. Make sure that the path and file name are correct.**

In this case, type Notepad in start search and right-click on the Notepad result. Select Run as administrator.

3. Once you get it opened you can start making changes. As with our Mac instructions you may wish to *copy your original file* just incase.

By default, a windows hosts file should be similar to the following:

**127.0.0.1 localhost**

You can add additional lines to this file that will point requests for a particular domain to your *new server’s IP address (see screenshot in step 1 of Mac)*. Example:

**127.0.0.1 localhost64.91.237.213 yourcooldomain.com64.91.237.213 www.yourcooldomain.com**

4. When finished, **Save** your changes.

5. You then want to* flush your DNS cache* by typing in **cmd** and the Windows search bat will appear on the right side. **Right-click** on Command Prompt and click Run as administrator. Type in: **ipconfig /flushdns**

6. Restart any open browsers and then visit your website in the browser of your choice!

Both of these solutions are very quick and efficient and allow you to *100% preview your website* on your new server prior to changing your DNS and going live to the general public.

You can also use the **cPanel preview** link **(i.e. http://64.91.237.213/~USERNAME)** but if you have hard-coded your domain on any images or links you may not get an accurate preview. This is especially the case when using WordPress.

If you have any questions or concerns, feel free to let us know, we’d be happy to help!

## Related posts

- [Test Your Site On A New Host Before Changing Your DNS Records](https://www.namehero.com/blog/test-your-site-on-a-new-host-before-changing-your-dns-records/)
- [Switching To The QUIC.cloud DNS](https://www.namehero.com/blog/switching-to-the-quic-cloud-dns/)
- [How to Fix the “DNS Server Not Responding” Error](https://www.namehero.com/blog/how-to-fix-the-dns-server-not-responding-error/)
