Editing your hosts file

Occasionally you need to edit your hosts file to see what a site looks like before the DNS has been switched over.

To do this, follow these steps below.

Windows

  • Click on the start menu, find Notepad, right click on it and "Run as administrator"
  • Choose "Open" from the file menu, and navigate to C:\Windows\System32\Drivers\etc\hosts (you will need to view "All Files" to see the hosts file)
  • Now add a line similar to the following at the bottom of your file, ensuring you replace "domainname.com.au" with the target domain name:
202.164.22.100   domainname.com.au
202.164.22.100 www.domainname.com.au
  • Choose "Save".
Note: If your hosting account is on a dedicated server or has a static IP, you will need to replace the above IP address with the IP of your hosting account

Mac/Linux

  • Open a terminal
  • Type the following command:
sudo pico /etc/hosts
  • Add a line similar to the following at the bottom of your file, ensuring you replace "domainname.com.au" with the target domain name:
202.164.22.100   domainname.com.au
202.164.22.100 www.domainname.com.au
  • Then hit cntl-x, y, enter
Note: If your hosting account is on a dedicated server or has a static IP, you will need to replace the above IP address with the IP of your hosting account

Browsing Sites

You may need to do a hard refresh or close your browser before it will load the new IP address when you browse to the site.

IMPORTANT

Once the site has gone live, it's a good idea to remove that line or comment it out (using a # character at the start of the line) so that you don't get confused later on.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Web Hosting Glossary

The following is a glossary of popular words associated with web hosting. ActiveX A loosely...