About the Hosts File
The “hosts” file is a file tells your computer where a specific domain (e.g. “mycooldomain.com”) lives. Each registered domain lives at a specific IP address. When you request a web page in your browser, your computer stores a record of the IP address at which it found the content, for faster lookup next time.
If you have migrated your website’s database and content to WP Engine but have not edited your DNS records, you can use a “hosts file trick” to tell your computer to look to WP Engine for your website’s content, instead of the current live location the rest of the world is seeing. This will effectively allow you to “preview” what your website will look like when you edit DNS to point to WP Engine!
Note: If you are following along on the Migration Checklist in the User Portal, this step is a little different. In the Verify Phase, you can with one click preview your site.
Step 1: Locate WP Engine IP Address
In order to point your domain to WP Engine on your local machine, you will need to know your WP Engine IP address. Your IP address is found in your User Portal, under the Overview page for your environment. For full steps, look to our How to Find Your IP Address article.
You can also simply ping [yourenvironment].wpengine.com to find your IP. If you don’t know how to ping, you may use this website service to find your IP: Site24x7
Step 2: Edit Hosts File
The main idea is that you will edit the hosts file to point your domain name to your WP Engine IP. You will add a new line in the hosts file with the format of “ip-address domain.com.” So for example, if your IP is 123.456.78.90 and your domain is mycooldomain.com, then you will add the following line into the hosts file:
The steps to editing the hosts file will vary depending on whether you run a PC or a Mac, and also on the version of your operating system. Because of the variations and since there is already good documentation on how to edit the hosts file, we’ve compiled a set of external resources, one of which will fit your particular operating system.
Mac OS X Documentation
Gas Mask (Mac OS X only)
On a Mac, there is a very helpful tool for editing your hosts file called Gas Mask. This application helps you easily manage multiple hosts file entries and edit without entering Terminal or using command line.
Step 3: Flush DNS
Last, you will need to flush the DNS on machine so it knows to read the new entries in your hosts file. Steps to flush DNS will vary based on the Operating System of your computer. We have included videos of each below.
Step 4: Relaunch Browser
In order for the hosts file settings to take into effect, please restart your web browser. You can now access your website hosted by WP Engine using the domain name.