· Tutorial ·

Modify 'hosts' file on Windows, Mac and Linux

In occasions when performing a migration, as well as in other circumstances, you will need to check the web content hosted with us, but keeping the server that your domain name is currently pointing to. This allows you to see that everything is working as expected before pointing your current domain to the SW Hosting server.

Your Quality Hosting from $0.85/month

Our Hosting gives you the freedom to tailor your website to your brand and goals.

We show you how to perform this check with each operating system.

Windows

  1. Locate the Notepad icon.
  2. Right click on the icon and select Run as administrator.
  3. Go to the File > Open menu and edit the following file on your computer:C:\Windows\System32\drivers\etc\hosts.
  4. Add a line with the IP of the new server followed by the domain, for example:81.25.123.45 swhosting.com www.swhosting.com.
  5. Save the changes, go to menu File > Save.

Now, when you access "swhosting.com", you will access it through the IP you have specified in the file (81.25.123.45) instead of the one the domain actually points to. These changes only affect the computer on which you have modified the "hosts" file.

For your domain to point to the new server for real, you will have to modify the domain nameserver or DNS zone (A record).

info Remember that you will have to delete this new line that you have just added.

Your Cloud SO from $5.60/month

Get the most out of your project with the fastest disks and most powerful CPUs in the Cloud.

Mac

  1. Open the Terminal, do a search on Spotlight to quickly locate it.
  2. Enter the following command to edit the hosts file:sudo nano /private/etc/hosts.
  3. You will need to enter the administrator password. Remember that the password characters will not be displayed as you type. Once entered, press Enter on your keyboard.
  4. Scroll to the end of the file with the arrow on your keyboard and add a line with the IP of the new server followed by the domain, for example: 81.25.123.45 swhosting.com www.swhosting.com.
  5. Save the changes by pressing Ctrl + O (letter, not number).
  6. Close the file by pressing:Ctrl + X.
  7. Finally enter the following command to reload the DNS cache:dscacheutil -flushchache.

Now, when you access "swhosting.com", you will access it through the IP you have specified in the file (81.25.123.45) instead of the one the domain actually points to. These changes only affect the computer on which you have modified the "hosts" file.

For your domain to point to the new server for real, you will have to modify the domain nameserver or DNS zone (A record).

info Remember that you will have to delete this new line that you have just added.

Linux

  1. Open the Terminal.
  2. Enter the following command to edit the hosts file:sudo nano /etc/hosts.
  3. Scroll to the end of the file with the arrow on your keyboard and add a line with the IP of the new server followed by the domain, for example:81.25.123.45 swhosting.com www.swhosting.com.
  4. Save the changes by pressing Ctrl + O (letter, not number).
  5. Close the file by pressing:Ctrl + X.

Now, when you access "swhosting.com", you will access it through the IP you have specified in the file (81.25.123.45) instead of the one the domain actually points to. These changes only affect the computer on which you have modified the "hosts" file.

For your domain to point to the new server for real, you will have to modify the domain nameserver (DNS servers) or the DNS zone (A record).

info Remember that you will have to delete this new line that you have just added.

i