Your computer resolves domain names (yoursite.com) to IP addresses via DNS service. The hosts file overrides this and allows you to hard code an IP address for your domain name for temporary testing purposes.
To open the file, do the following steps
1. Command + Space will bring up your Spotlight search (Magnifying glass in the upper right of your screen)
2. Start typing "terminal".
3. Select the terminal application
Note: The Terminal is a program included with all versions of Mac OSX When launched, it provides a command line to control of the UNIX based operating system.
4. Copy and paste this command: osascript -e 'tell application "TextEdit" to open "/etc/hosts"'
5. Edit the file to include the temporary IP address and domain name, save the file.
Note: The formatting of this file is critical. Each line may have one IP address followed by a [tab] and multiple domain names separated by a space.
Example Line: 22.214.171.124 yoursite.com www.yoursite.com
6. Flush the DNS cache by typing this command in your terminal window:
Your domain name should now resolve to your hard coded IP address. When you are done testing be sure to open the hosts file again and remove the lines you added.