Hosts file, website testing

Dedicated Server

Dedicated server

Check out SIM-Networks’ powerful pre-made server configurations

See packages

In some cases, for example, when the site needs to be tested on a new server or hosting without disrupting its operation on the existing one, or when the domain for the site has not yet been registered, it becomes necessary to override the domain settings locally, only to the device from which the test is being carried out.

This can be done using a special file - hosts.

  • For Windows OS, it is located along the path: %SystemRoot%/system32/drivers/etc/hosts (where %SystemRoot% is most often C:Windows)
  • For most Linux family OS: /etc/hosts
  • And for Apple OS: /private/etc/hosts or /etc/hosts

In this file, you need to add construction of the form from a new line: IP address domain name For example: 123.45.67.89 mydomain.com After that, save the changes (these actions are performed only with administrator rights, otherwise the result will not be achieved).

As a result, requests to the mydomain.com domain will be directed to the address 123.45.67.89, regardless of the settings of the mydomain.com domain and even if it does not exist, because settings from the host's file are processed before DNS queries.

Was this article helpful?

Did you like the article?

Cookie consent

By clicking «I agree», you consent to our website's use of cookies to give you the most relevant experience by remembering your preferences and repeat visits. However, you may visit «Manage сookies» to provide controlled consent. Learn more

Cookies settings

functional

Necessary cookies are crucial for the basic functions of the website and the website will not work in its intended way without them.

Analytics

Analytical cookies are used to understand how visitors interact with the website.

Advertisement

Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns.