Hosts file windows 10

by Yogi P - May 26, 2022

What is Hosts file ?

Hosts file is an systems file of a operating system that maps hostnames to IP addresses. It is a plain text file.

Purpose of Hosts file

The hosts file assists in addressing network nodes in a computer network. Hosts file is a common part of an operating system’s Internet Protocol (IP) implementation, and translate human-friendly hostnames into numeric protocol addresses, called IP addresses, help to identify and locate a host in an IP network.

Content of Hosts file

The hosts file contains lines of text which contains an IP address in the first text field followed by a human-friendly hostname. These fields are separated by whitespace . It can contain comment lines also. Blank lines in the file are ignored. For example, a default hosts file contents may look like the following:

127.0.0.1 localhost loopback
::1 localhost

These above entries are for the loopback addresses of the system and their host names, it is a typical default content of a hosts file in the system. It is clear that an IP address can have multiple host names, and a host name can be mapped to IPv4 and IPv6 IP addresses both.

Location of Hosts file in different file systems and OS

The location of the hosts file varies according to operating system. Generally it is named as hosts, without any extension.

Operating System Version(s) of OS Location of Hosts files
Unix, Unix-like, POSIX /etc/hosts
Microsoft Windows 3.1 %WinDir%\HOSTS
95, 98, ME %WinDir%\hosts
NT, 2000, XP, 2003, Vista,
2008, 7, 2012, 8, 10, 11
%SystemRoot%\System32\drivers\etc\hosts
Windows Mobile, Windows Phone Registry key under HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts
Apple Macintosh 9 and earlier Preferences or System folder
Mac OS X 10.0–10.1.5 (Added through NetInfo or niload)
Mac OS X 10.2 and newer /etc/hosts (a symbolic link to /private/etc/hosts)
Novell NetWare
OS/2, eComStation, ArcaOS “bootdrive”:\mptn\etc\
Symbian Symbian OS 6.1–9.0 C:\system\data\hosts
Symbian OS 9.1+ C:\private\10000882\hosts
MorphOS NetStack ENVARC:sys/net/hosts
AmigaOS < 4 AmiTCP:db/hosts
4 DEVS:Internet/hosts
AROS ENVARC:AROSTCP/db/hosts
Android /etc/hosts (a symbolic link to /system/etc/hosts)
iOS iOS 2.0 and newer /etc/hosts (a symbolic link to /private/etc/hosts)
TOPS-20 <SYSTEM>HOSTS.TXT
Plan 9 /lib/ndb/hosts
BeOS /boot/beos/etc/hosts
Haiku /system/settings/network/hosts
OpenVMS UCX UCX$HOST
TCPware TCPIP$HOST
RISC OS 3.7, 5 !Boot.Resources.!Internet.files.Hosts
later boot sequence !Boot.Choices.Hardware. Disabled. Internet.Files.Hosts

How to modify hosts file

Modifying hosts file of your system enables you to override the domain name system (DNS) for a particular domain on your system/machine. DNS management is very useful when we want to test our site prior to going live with SSL, can verify that an alias site will work properly.

Modifying your hosts file tells your local machine to look directly at the Internet Protocol (IP) address that you specify in hosts file. Modifying of a hosts file involves adding two entries in it. Each entry contains the IP address to which you want the site to resolve with the version of the Internet address.

Sample two entries points, www.domain.com and domain.com, to an IP address:

64.49.219.194 www.poonamyogi.in

64.49.219.194 poonamyogi.in

After adding these lines of code the system will resolve poonamyogi.in to IP 64.49.219.194

Here are the instructions for locating and editing the hosts file on the following operating systems:
  • Windows Vista™, Windows 7, Windows 8 and Microsoft® Windows® 10
  • Windows XP,  Windows 2000, and  Microsoft Windows NT™
  • Linux®
  • MacOS® X versions 10.0 to 10.1.5
  • MacOS X versions 10.6 to 10.12

Hosts file in Windows

In Microsoft operating system like Windows 7, Windows 8, Windows 10, and Windows Vista you must run Microsoft Notepad as an administrator.

Hosts file in MIcrosoft Windows 10 and Windows 8 Operating systems

  • Press the Windows key in keyboard.
  • Located search field and type Notepad to search.
  • Now when search results come, right-click on Notepad and select Run as administrator.
  • Now when Notepad is open then open the following file in it:
  • c:\Windows\System32\Drivers\etc\hosts
  • Make the necessary changes required to the file.
  • Once done the changes required, then save the changes in file by selecting File > Save.
  • Change in hosts file is done

Hosts file in Microsoft Windows 7 and Windows Vista Operating systems

  • Click Start > All Programs > Accessories.
  • Right-click on Notepad and then select Run as administrator.
  • Now the Windows will ask your permission UAC window appears.
  • Click Continue button to grant your permission.
  • Now the Notepad will open.
  • Once Notepad is open, select File > Open.
  • Now browser to this following path of hosts file:
  • C:\Windows\System32\Drivers\etc\hosts
  • Select hosts file and click Open.
  • Make the necessary changes as required to the file.
  • After doing the changes required, save the changes in file by selecting File > Save.
  • Change in hosts file is done.

Hosts file in Microsoft Windows NT, Windows 2000, and Windows XP Operating systems

  • Click Start > All Programs > Accessories > Notepad.
  • Click File > Open.
  • Now browse the hosts file from this path C:\Windows\System32\Drivers\etc\hosts.
  • Select hosts file and click Open.
  • Make the required changes to the file.
  • After doing the changes required, save the changes in file by selecting File > Save.
  • Changes are saved.

How to edit Hosts file in Linux

  • Open a terminal window in linux.
  • Enter => sudo nano /etc/hosts command to open the hosts file in nano text editor in terminal
  • It will ask for your sudo password, enter password.
  • Now the file will open in nano editor and you can make the necessary changes to the file.
  • Once changes are done then, press Control-X.
  • It will ask you if you want to save your changes, enter y. and press enter
  • Your hosts files will be saved.

Amending Hosts file in MacOS X versions 10.0 to 10.12

MacOS X 10.0 through 10.1.5

  1. Open -> Applications -> Utilities -> NetInfo Manager.
  2. Click the padlock icon to enable editing of the Network Information database (NetInfo), padlock icon is in the lower-left corner of the window.
  3. Now enter your domain user password and select OK.
  4. Select the node named machines from the second column of the browser view.
  5. Select the entry named localhost in third column.
  6. Select Duplicate from the Edit menu. A confirmation alert will appear.
  7. Now click Duplicate then a new entry named localhost copy will appear with its properties displayed below the browser view.
  8. Enter the IP address of the other computer by double-clicking the value of the ip_address property
  9. Enter the host name which you want use for the other computer by double-clicking the value of the name property.
  10. Now click the serves property and select Delete from the Edit menu.
  11. Select Save from the File menu. A confirmation alert will appear.
  12. Now click Update this copy.
  13. Repeat steps 6 through 12 for each additional host entry that you want to add.
  14. Once done then select Quit from the NetInfo Manager menu.
  15. Restart the computer if it ask for it.

How to amend Hosts file in MacOS X 10.6 through 10.12

  • Open a Terminal window in your MAcOS machine.
  • Enter sudo nano /private/etc/hosts command in the Terminal window to open the hosts file:
  • Enter your domain user password when you are prompted.
  • Now the hosts file will open for edit in nano editor in terminal.
  • Amend the file as required.
  • Now to save the hosts file, press Control+X.
  • It will ask you if you want to save your changes, enter y and press enter.
  • Now finally to force your changes to take effect, you should flush the DNS cache by using dscacheutil -flushcache  command.

Share on: Share YogiRaj B.Ed Study Notes on twitter Share YogiRaj B.Ed Study Notes on facebook Share YogiRaj B.Ed Study Notes on WhatsApp
Latest Posts

CDMA Full Form

April 19, 2024

Table of 14

April 11, 2024

Tables 11 to 20

March 11, 2024

Tense Chart

December 22, 2023

Table of 13

December 20, 2023
Search this Blog
Categories