Knowledgebase
Knowledgebase
How To Edit Hosts File
Posted by Will Kruss on 09 March 2017 01:49 PM

On occasion you will need to edit the hosts file on your machine. VPSBlocks provides details on how to edit hosts file.

If you want to make your local computer believe that your website is hosted on your new VPS before you modify the actual DNS, this can easily be done by modifying your hosts file.

Windows

  • Click the 'Start' button in Windows on your LOCAL computer
  • Type in: notepad
  • Right click on the link to notepad that appears, and choose 'Run as Administrator'
  • When notepad opens go to File -> Open
  • Browse to c:\windows\system32\drivers\etc
  • Open the file 'hosts' in notepad
  • Add a lines to the bottom:

x.x.x.x www.yourdomain.com
x.x.x.x yourdomain.com

  • Where x.x.x.x is your VPSBlocks VPS IP address and yourdomain.com is the domain you use to access your website.
  • Save the file.
  • Close all instances of your browser.
  • Reopen your browser and browse to www.yourdomain.com and what you see will be served from your new VPS.

Once you have completed any testing always modify your hosts file again and remove the lines you added.

MAC

You need to edit the file at /private/etc/hosts

If you aren't sure how to do this follow these instructions:

1. Open Terminal

2. Type: sudo nano /private/etc/hosts

3. Enter your administrator password when prompted

4. Edit the file in the same format as for Windows above e.g.
x.x.x.x domain.com
x.x.x.x www.domain.com

5. Press Ctrl-o to save the file

6. Press Enter to confirm saving the file

7. Close all instances of your browser.

8. Reopen your browser and browse to www.yourdomain.com and what you see will be served from your new VPS.

Once you have completed any testing always modify your hosts file again and remove the lines you added.

 

(1 vote(s))
Helpful
Not helpful