Skip to main content

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:

File hosts 1

Type in ping example.com, where example.com is the website that you are interested in:

File hosts 2

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:

File hosts 3

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:

File hosts 4

Press File -> Open:

File hosts 5

Open the c:\windows\system32\drivers\etc\hosts

File hosts 6

By default, the file contains the following:

File hosts 7

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:

File hosts 8

Let's check. IP should change. In rare cases, it is necessary to reboot the PC and/or clear the browser's cache.

File hosts 9