Host FIle

How to Use the Hosts File

 

Modifying your hosts file allows you to override the DNS for a domain, on that particular machine. This is useful when you want to test your site without the test link, prior to going live with SSL; verify that an alias site works, prior to DNS changes; and for other DNS-related reasons. Modifying your hosts file causes your local machine only to look directly at the IP address specified.

You can direct all traffic from your local computer to access your website on a specific servers without the need of pointing your domain. In order to perform this you should edit your hosts file on that particular computer. Depending on the OS (operational system) you need to use the following steps:

Windows Users

If you are using Windows OS you should access the hosts file from:

C:\Windows\System32\Drivers\etc\

You can open the hosts file with your favorite text editor. If you receive this message: "File operation failed. Access is denied", you will have to open the file as administrator. In the file you should write:

xxx.xxx.xxx.xxx domain.com

where "xxx.xxx.xxx.xxx" is the IP address of the server, where your website is hosted and "domain.com" is the actual domain name set on your website.

Mac OS Users

If you are using Mac OS X, you should access Applications → Utilities → Terminal. Once the terminal is accessed, write the following command:

sudo nano /private/etc/hosts

Type your user password when prompted. Once the hosts file is accessible for changes, you should enter the following line

xxx.xxx.xxx.xxx domain.com

where "xxx.xxx.xxx.xxx" is the IP address of the server, where your website is hosted and "domain.com" is the actual domain name set on your website.

Linux Users

Last, but not least, the Linux users will have to open terminal window. Access the hosts file with the following command:

sudo nano /etc/hosts

On a new line in the file enter:

xxx.xxx.xxx.xxx domain.com

where "xxx.xxx.xxx.xxx" is the IP address of the server, where your website is hosted and "domain.com" is the actual domain name set on your website.

When you complete the changes on your hosts file, you can save it and access your website the usual way. It will lead to the specific server that you defined in the hosts file and you will be able to test from your local machine without pointing your actual domain.

  • 0 Корисниците го најдоа ова како корисно
Дали Ви помогна овој одговор?

Понудени резултати

Cache Clearing

1. Google Chrome Windows & macOS: Open Chrome. Access Settings: Click on the three...