How to add domain names and IP addresses in the hosts file
You need to map the domain name and the IP address in the hosts file if: • DNS records have been changed and your DNS provider has not updated the cache; • you need to access a website on a new or an old server from your PC without changing DNS.
To find out the IP address that maps to the domain name on your PC, you can use the ping command.
Go to the Start menu and find the Command prompt (you can click on the Start menu and enter cmd
or command prompt
:
Type in ping example.com
, where example.com is the website that you are interested in:
To map the domain name to the IP address in the hosts file, open Notepad or any other text editor in the Start menu. Right-click on it and select Run as Administrator:
A window will open. You will be asked to either type in the administrator's password or to confirm access rights escalation. Type in the password and confirm:
Press File -> Open:
Open the c:\windows\system32\drivers\etc\hosts
By default, the file contains the following:
Add the IP address and the domain name to the end of the document. Note that the string after the # symbol is not processed. You can add your comment there:
Let's check. IP should change. In rare cases, it is necessary to reboot the PC and/or clear the browser's cache.