Modify Your Hosts File

Modifying your hosts file enables you to override the DNS for a domain, on that particular machine. This is useful when you want to test your site without the test link, prior to going live with SSL; verify that an alias site works, prior to DNS changes; and for other DNS-related reasons. Modifying your hosts file causes your local machine to look directly at the IP address specified.

To modify the hosts file, you add two entries to the file that contains the IP address that you want the site to resolve to and the address. Adding the following two lines, for example, point www.domain.com and domain.com to our current PHP5-ITK (“Refreshed” PHP5) cluster:

64.49.219.194 www.domain.com
64.49.219.194 domain.com

After you add the domain information and save the file, your system begins resolving to the specified IP address. After testing is finished, remove these entries.

Windows

Windows 10, Windows 8, Windows 7, and Windows Vista use User Account Control (UAC), so Notepad must be run as Administrator.

For Windows 10 and 8

  1. Press the Windows key.
  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.

Windows NT, Windows 2000, and Windows XP

  1. Click Start > All Programs > Accessories > Notepad.
  2. Click File > Open.
  3. In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
  4. Click Open.
  5. Make the necessary changes to the file.
  6. Click File > Save to save your changes.

Mac OS X 10.0 through 10.11

As if July 2nd, 2019, here’s the best updated method.

Mac OS X 10.0 through 10.1.5

  • Open /Applications/Utilities/NetInfo Manager.
  • To allow editing of the NetInfo database, click the padlock in the lower-left corner of the window.
  • Enter your domain user password and click OK.
  • In the second column of the browser view, select the node named machines.The third column contains entries for -DHCP-, broadcasthost, and localhost.
  • In the third column, select localhost.
  • From the Edit menu, select Duplicate. (The quickest way to create a new entry is to duplicate an existing one.)A confirmation alert appears.
  • Click Duplicate.A new entry called localhost copy appears, and its properties are shown below the browser view.
  • Double-click the value of the ip_address property and enter the IP address of the other computer.
  • Double-click the value of the name property and enter the hostname you want for the other computer.
  • Click the serves property and select Delete from the Edit menu.
  • From the File menu, select Save.A confirmation alert appears.
  • Click Update this copy.
  • Repeat steps 6 through 12 for each additional host entry that you want to add.
  • From the NetInfo Manager menu, select Quit.You do not need to restart the computer.

Linux

  1. Open a terminal window.
  2. Open the hosts file in a text editor (you can use any text editor) by typing the following line:nano /etc/hosts
  3. Enter your domain user password.
  4. Make the necessary changes to the file.
  5. Press Control-x.
  6. When asked if you want to save your changes, answer y.

Anthony Scolaro

A serial entrepreneur and technology enthusiast, Anthony Scolaro’s small business ventures began in 2009 Over the years, Anthony channeled his passion for creating solutions-driven processes and exceptional service and launched Project Assistant in the summer of 2011.

An innovative technology firm that partners with businesses to develop comprehensive web marketing, design, brand and mobile app development solutions, Project Assistant has become a rapidly growing and value-added entity for small to medium-sized companies in the U.S., Europe and across SE Asia. Serving as the firm’s CEO and Founder, with offices located in Charleston and the Philippines, Project Assistant merges diversity, ingenuity and a love for the tech space to help organizations gain a larger segment of the market while maximizing continuous integration and pipelines for expedited scalability.

Whether a client needs to design and engineer a web or mobile app, internet marketing, systems administration, website traffic growth, or clarity in defining its brand, Anthony offers strategic solutions, a passion for technology and all-American southern hospitality to take organizations to new heights.