This article explains how you can quickly and easily edit your .hosts file in Windows.
A hosts file is a plain-text file used by your Windows PC to map hostnames to IP addresses.
Modifying your computers hosts file is a useful if you wish to preview your website on Ecenica without modifying your domain name. Editing your hosts file can also be useful after registering a new domain name, recent domain transfer or DNS update. See How long does it take for my domain name to become active?
How does it work?
When you view a website your computer looks at it’s .hosts file to try and map the site host-name to an IP address. If a match is not found, your computer tries to find an IP address using the Domain Name System (DNS).
Editing your .hosts file let’s you intercept the DNS lookup and redirect your domain to another IP address.
The computer at the receiving IP address needs to answer to your domain name.
Why update my .hosts file?
- Easy migration. You can publish and test your site on your Ecenica web space without taking your old site offline.
- Faster web development. You can develop and test your site on your local server using your domain name.
- Redirect your domain to a local IP address.
- Simple and easy to use.
How do I change my .hosts file?
To view your website before updating your domain’s name servers or DNS records you will need to change your HOSTS file to point to your Ecenica IP address (Computer).
- Click Search the web and Windows
- Type Notepad
- Right-click Notepad and select Run as administrator
- Click Yes on the User Account Control prompt
- In Notepad, click File > Open
- Change the file filter drop down box from ‘Text Documents (.txt)’ to ‘All Files (.*)’
- Right-click the address bar and select Edit address
- Type C:\Windows\System32\Drivers\etc and press the Enter key
- Select the hosts file and click Open.
- At the bottom of the file, insert your Ecenica web servers IP address and your domain name. For example: 100.100.100.100 example.com.
- Close Notepad. Click Save when prompted.
Example hosts file with 100.100.100.100 example.com added.
# Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # #My Ecenica Websites 100.100.100.100 example.com 100.100.100.100 www.example.com
After you’ve changed your hosts file we recommend you flush your DNS. This will make your PC pick-up the new changes faster.
- Click Start.
- Type cmd.
- Right-click Command Prompt and select Run as administrator.
- Click Yes on the User Account Control prompt.
- Enter ipconfig /flushdns
- Press the Enter key.