2.5. hosts file

In the previous section, localhost was used as the domain, which is a pseudonym for the IP address 127.0.0.1. On the local host, the alias for the IP address is specified in the hosts file, which in a UNIX-like operating system can be found in /etc/hosts, and in Windows in C:\Windows\system32\drivers\etc\hosts.

Как правило, в файле присутствуют как минимум две записи, сопоставляющие домену localhost локальный IР-адрес 127.0.0.1 в 1Pv4- и 1Рv6-форматах:

127.0.0.1 localhost
::1 localhost

It is the presence of these records allowed us to launch the built-in server using localhost as the domain. In order to configure alternative aliases, you can add additional entries:

127.0.0.1 site.dev
127.0.0.1 www.site.dev
127.0.0.2 project.dev
127.0.0.2 www.project.dev

IP addresses starting with 127 are intended for local use, so you can assign any address from this range to test your own projects.

After adding new aliases to the hosts file, they can be used in conjunction with the built-in server, for example http://site.dev:4000/.