Emulate DNS Locally with the Hosts File Trick

The “hosts” file is a file tells your computer which IP a specific domain points to. This speeds up the connection time the next time you request the page.

By modifying this file, you can trick your local computer into thinking that a domain lives at a different IP address than is currently set with your DNS host.

In short- You can test your site on WP Engine servers after migrating using your live site’s content, but without actually taking the changing any DNS. The change is local so this also means no one sees it this way but you.

Locate WP Engine IP

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.

Edit Hosts File

You will edit the hosts file so that your domain name directly corresponds to your WP Engine IP on the same line. You will add a new line to the local hosts section of your host file with the format of: ipaddress domain.com

For Example:

Your IP is 123.456.78.90

Your domain is mycooldomain.com

You will add the following line to the hosts file:

123.456.78.90 mycooldomain.com

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.

Windows operating systems
Mac operating systems

Windows Documentation

We suggested using this comprehensive, external guide if you’re connecting from a Windows machine: Beginner Geek “How To Edit Your Hosts File”

There is also a great video guide of the steps here:

Mac OS X Documentation

We suggested using this comprehensive, external guide if you’re connecting from a Mac machine: How to edit the hosts file in Mac OS X

There is also a great video guide of the steps here:

NOTE: On a Mac, there are two helpful tools for editing your hosts file called iHosts and Gas Mask. These applications help you easily manage multiple hosts file entries and edit without entering Terminal or using command line.

Flush DNS

Last, you will need to flush the DNS cache on your machine so it knows to read the new entries in your hosts file instead of the old, saved entries. On many devices restarting will clear this cache, however to ensure the changes are being observed, we recommend following the steps to manually flush your DNS cache.

Steps to flush DNS will vary based on the Operating System of your computer. We have included videos of each below.

Windows 10

Windows 8


Relaunch Browser

In order for the hosts file settings to take effect, please restart your web browser completely. You can now access your website hosted by WP Engine using the domain name as normal in your browser.

To revert the changes, simply delete the line added to your host file, or comment it out. Then flush DNS and restart your browser.

NEXT STEP: Going live with a domain on WP Engine

Still need help? Contact support!

We offer support 24 hours a day, 7 days a week, 365 days a year. Log in to your account to get expert one-on-one help.

The best in WordPress hosting.

See why more customers prefer WP Engine over the competition.