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.
cta:hosting
We show you how to perform this check with each operating system.
Windows
- Locate the Notepad icon.
- Right click on the icon and select Run as administrator.
- Go to the File > Open menu and edit the following file on your computer:
C:\Windows\System32\drivers\etc\hosts
.
- 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
.
- 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.
cta:cloud_so
Mac
- Open the Terminal, do a search on Spotlight to quickly locate it.
- Enter the following command to edit the hosts file:
sudo nano /private/etc/hosts
.
- 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.
- 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
.
- Save the changes by pressing
Ctrl + O (letter, not number)
.
- Close the file by pressing:
Ctrl + X
.
- 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
- Open the Terminal.
- Enter the following command to edit the hosts file:
sudo nano /etc/hosts
.
- 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
.
- Save the changes by pressing
Ctrl + O (letter, not number)
.
- 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.