The following instructions are advanced steps for forcing your local machine to view a website prior to the DNS changes propagating. Please keep in mind that the normal wait time for propagation of nameservers is 48 hours.
- 127.0.0.1 localhost
- 188.8.131.52 www.example.com
Add the second line in this example to your hosts file, but be sure to use the server IP that HostGator provided you and your actual domain name.
Windows users are able to edit their host file directly from their PC.
Windows 7 or Vista
- Browse to Start > All Programs > Accessories.
- Right-click Notepad, and select Run as administrator.
- Click Continue on the UAC prompt.
- Click File > Open.
- Browse to C:/Windows/System32/Drivers/etc.
- Change the file filter drop-down box from Text Documents (*.txt) to All Files (*.*).
- Select hosts, and click Open.
- Make the needed changes, as shown above, and close Notepad.
- Save when prompted.
Windows XP and Lower
- If you are using Windows, use "Start," "Find" and "Files and Folders" to find a file in your windows directory (or WINNT\system32\drivers\etc) called hosts.
- Verify that the file is not "read only" by right-clicking it, and choosing Properties.
- Open the file for editing with Notepad. There should already be an entry for "localhost." Be sure to follow the same format when inserting the HostGator IP and the domain name.
On Windows2000 and WindowsME, the order is IP address, hostname.
- Save this altered hosts file and close notepad. Make sure Windows did not silently save the file as hosts.sam. The filename has to be hosts.
Mac OS X
Follow the instructions below if you are running Mac OS X and want to preview your site on our servers without changing DNS:
- Open the Terminal application. Start by typing Terminal on the Spotlight or by going to Applications > Utilities > Terminal.
- Open the hosts file by typing in the Terminal that you have just opened:
sudo nano /private/etc/hosts
Please note: Some versions of Mac OS X will chattr the hosts file. In the event this happens and the file is marked immutable, use the following command instead: sudo chflags nouchg /private/etc/host
- Type your user password when prompted.
- The hosts file contains some comments (lines starting with the # symbol), as well as some default hostname mappings (e.g. 127.0.0.1 localhost). Simply append your new mappings underneath the default ones. You can navigate the file using the arrow keys.
IPGOESHERE domain.com www.domain.comReplace domain.com with your actual domain name. Additional domains, subdomains or addon domains can be added at the end of the line, separated by spaces.
- When done editing the hosts file, press control-o to save the file.
- Press enter on the filename prompt, and control-x to exit the editor.
On Unix-based systems, you can find the hosts file at /etc/hosts. Most distributions of Unix will have terminal located in the same location.
To open the terminal:
- Go to Menu.
- Select Applications.
- Choose Accessories.
- Select Terminal.
To edit the hosts file:
Unix users can edit hosts files in the same process as Mac users. Please refer to steps 2 through 4 in the Mac section above.
Once you have modified your hosts file, it is recommended that you flush your DNS so that the new changes can be implemented more swiftly. DNS flushing must be done using command line. Depending on your computer's OS, there will be different commands.
For more information on Flush DNS, please see the following related article: