---
title: "Previewing your domain"
date: "2014-10-31"
category: "dns"
slug: "previewing-your-domain"
---

When switching hosting providers, you may want to preview how your site looks on the new server before updating your [[nameserver-settings]]. You can do this by editing your computer's [hosts file](http://en.wikipedia.org/wiki/Hosts_file), which overrides DNS for specific hostnames.

## Hosts File Syntax

All hosts files use the same format:

`<IP ADDRESS> <HOSTNAME>`

For example, the following entry forces `apnscp.com` to resolve to `64.22.68.1`:

`64.22.68.1 apnscp.com`

After saving this change, visiting `http://apnscp.com` in your browser will load the site from `64.22.68.1` regardless of public DNS. Your server's IP address is available in the control panel under **Account** > **Summary** > **General Information** > **IP Address**.

## Editing the Hosts File by OS

### Windows (Vista, 7, and later)

1. Open the **Start** menu and navigate to **All Programs** > **Accessories**
2. Right-click **Notepad** and select **Run As Administrator** (accept the UAC prompt if shown)
3. Go to **File** > **Open** and enter `%SystemRoot%\system32\drivers\etc\hosts`
4. Add your entry, save the file, and close Notepad

![Sample hosts file from Windows](kb-image:Hosts-windows.png)
*Sample hosts file from Windows*

DNS changes take effect immediately after saving.

### macOS

1. Open Terminal and run: `sudo nano /private/etc/hosts`
2. Add your entry, then press **CTRL + O** to save and **CTRL + X** to exit
3. Flush the DNS cache: `sudo dscacheutil -flushcache`

### Linux

1. Open a terminal and run: `sudo nano /etc/hosts`
2. Add your entry, then press **CTRL + O** to save and **CTRL + X** to exit

DNS changes take effect automatically on Linux.

## See Also

- macOS documentation: [How to add hosts to local hosts file](http://support.apple.com/kb/TA27291?viewlocale=en_US&locale=en_US)
- Linux man pages: [hosts(5)](http://apnscp.com/linux-man/man5/host.conf.5.html)
