The hosts file is a local file on your computer that maps domain names to IP addresses. Editing it lets you preview a website on a new server before going live with the site on the new server.
- Step 1: Open Notepad as Administrator
The hosts file requires administrator privileges to edit.- Press the Windows key, then type Notepad
- Right-click Notepad in the search results
- Select “Run as administrator”
- Click Yes if prompted by User Account Control (UAC)
- Step 2: Open the Hosts File
- In Notepad, go to File ? Open
- Navigate to the following path:
C:\Windows\System32\drivers\etc - In the file type dropdown (bottom right), change it from “Text Documents (*.txt)” to “All Files (.)”
- Select the file named hosts and click Open
- Step 3: Add Your Entry
- Scroll to the bottom of the file. Add a new line in this format:
000.000.000.000 yourdomain.com - Replace 000.000.000.000 with the IP address you were given, and yourdomain.com with the actual domain.
Example:
192.168.1.100 example.com
192.168.1.100 www.example.comMake sure there is at least one space or tab between the IP address and the domain name.
- Scroll to the bottom of the file. Add a new line in this format:
- Step 4: Save the File
- Go to File ? Save (not “Save As”). The file has no extension, so saving directly is important.
- Step 5: Flush Your DNS Cache
To make sure Windows picks up the change immediately:- Press Windows key + R, type cmd, and press Enter
- In the Command Prompt, type:ipconfig /flushdns
- Press Enter. You should see a confirmation message.
- Step 6: Verify It’s Working
Open your browser and navigate to the domain. You should now be seeing the site from the IP address you specified.