Modifying your HOSTS file to preview sites in Cloud

Many times you need to check a site in Cloud before switching the DNS to launch it there. You can do this on the real URL by modifying your hosts file. Don't forget to change it back when you're done! An example hosts entry would look like the following:

75.126.220.28 example.com www.example.com preview.example.com

This would tell your local computer to use that IP for those sites, despite what their DNS record says.

 

For Mac OS X OS X 10.6 (Snow Leopard) through macOS 10.12 (Sierra)

The easiest way is to simply install the open source hosts.prefpane. To do it manually like the cool kids, use the following Instructions:

  1. Open Terminal.app. The easiest way to do this is type cmd+space and search for it with Spotlight.
  2. Type the following to modify you hosts file:

    sudo nano /private/etc/hosts
    
  3. Type your admin password at the prompt.
  4. Edit the hosts file, per the example above.

    The file contains some comments (lines starting with the # symbol), and some default hostname mappings (for example, 127.0.0.1 – local host). Add your new mappings after the default mappings.

  5. Save the hosts file by pressing control+x and answering y.
  6. Flush your local DNS cache to make the change take effect:

    dscacheutil -flushcache
    

 

For Windows 10 and 8

  1. Press the Windows key on your keyboard. See? Windows is better. Because, one essey butten!
  2. Type Notepad in the search field.
  3. In the search results, right-click Notepad and select Run as administrator.
  4. From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
  5. Make the necessary changes to the file.
  6. Click File > Save to save your changes.

 

For Windows 7 and Vista

  1. Click Start > All Programs > Accessories.
  2. Right-click Notepad and select Run as administrator.
  3. Click Continue on the Windows needs your permission UAC window.
  4. When Notepad opens, click File > Open.
  5. In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
  6. Click Open.
  7. Make the necessary changes to the file.
  8. Click File > Save to save your changes.

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.