The hosts file is used by the operating system to determine the address of certain resources instead of requesting DNS. If the address of a certain resource is specified in the hosts file, the request will not be sent to DNS-server for receiving domain data, when opening a domain - it will open exactly from the address specified in the hosts file. The use of this file is quite convenient for testing the operation of a site from another server without directing the domain directly to this server.
Location of the hosts file
C: /Windows/System32/Drivers/etc/hosts
or %SystemRoot%\system32\drivers\etc\hosts
, but it can be changed in the registry.
You can use the Registry Editor to check the path to the hosts file. To do this, you need to click on Win +R , enter regedit
and click " OK ". The required parameter can be found along this path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\DataBasePath
.
To quickly open a file with administrator rights, you need to click Win +R , specify the path to the file C: /Windows/System32/Drivers/etc/hosts
and holding the buttons Ctrl +Shift , click on the " OK ».
Editing the hosts file
The hosts file contains entries in the form IP
domain
between which a tab should be set (to indent, just press Tab ), everything after the symbol #
is considered a comment:
In this example, there are three entries:
-
Direction
localhost
on IPv4127.0.0.1
(a call to localhost is a call to oneself). -
Direction
localhost
on IPv6: : 1
(equivalentto0: 0: 0: 0: 0: 0: 0: 1
). -
Example direction
example.com
on IPv4XXX.XXX.XXX.XXX
.
/etc
on OS X is a symbolic link to /private/etc
.