The Full Wiki

Hosts file: Wikis


Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.


From Wikipedia, the free encyclopedia

The hosts file is a computer file used in an operating system to map hostnames to IP addresses. This method is one of several system facilities to address network nodes on a computer network. On some operating systems, the host file content is used preferentially over other methods, such as the Domain Name System (DNS), but many systems implement name service switches to provide customization. Unlike DNS, the hosts file is under the control of the local computer's administrator.[1]

The hosts file is a plain-text file and is traditionally named hosts.



The ARPANET, the predecessor of the Internet, had no distributed host name database, such as the modern Domain Name System for retrieving a host's network node address. Each network node maintained its own map of the network nodes as needed and assigned them names that were memorable to the system's users. There was no method for ensuring that all references to a given node on a network were using the same name, nor was there a way to read some other system's hosts file to automatically obtain a copy.

The small size of the ARPANET made the use of hosts files practical. Network nodes typically had one address and could have many names. As individual TCP/IP computer networks gained popularity, however, the maintenance of the hosts file became a larger burden on system administrators as networks and network nodes were being added to the system with increasing frequency.

Standardization efforts, such as the format specification of the file HOSTS.TXT in RFC 952, and distribution protocols, e.g., the hostname server described in RFC 953, helped with these problems, but the centralized and monolithic nature of host files eventually necessitated the creation of the distributed Domain Name System.

Content and location

The hosts file contains lines of text consisting of an IP address and one or more hostnames, each field separated by white space (blank or tabulation characters). Comment lines may be included; they are indicated by a hash character (#) in the first position of such lines. For example,

#This is an example of the hosts file  localhost loopback

may be the entry for the loopback address and hostname, a typical default content of the host file.

The location of the hosts file in the file system hierarchy of operating systems varies.[2]

Operating System Version(s) Location
Windows 95, 98, Me %WinDir%\
NT, 2000, XP, 2003, Vista, 7 %SystemRoot%\system32\drivers\etc\ (see note)
Windows Mobile Registry key under \HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts
Macintosh 9 and earlier System Folder: Preferences or System folder
Mac OS X, iPhoneOS /private/etc/hosts or /etc/hosts (/etc on Mac OS X is a symbolic link to /private/etc)
Most Unix and Unix-like OSes /etc/hosts[3]
Novell NetWare SYS:etc\hosts
OS/2 & eComStation "bootdrive":\mptn\etc\
Symbian Symbian OS 6.1-9.0 C:\system\data\hosts
Symbian OS 9.1+ C:\private\10000882\hosts (AllFiles capable only)
Android /system/etc/hosts

On Microsoft Windows, %SystemRoot%\system32\drivers\etc\ is the default location. Users of 64-bit versions of Windows XP, Windows Server 2003, Server 2008, and Vista but not Windows 7 cannot access the HOSTS file with a 32-bit editor.[4] The actual location is defined in Registry key \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath.

Other uses

In its function of resolving host names, the hosts file may be used to define any domain name for use in the local system. This may be used either beneficially or maliciously for various effects.


Redirecting local domains

Some web service and intranet developers, and administrators enable locally defined domains on a LAN for various purposes, such as accessing the company's internal resources or to test websites in development.

Internet resources blocking

Special entries in the hosts file may be used to block online advertising, or the domains of known malicious resources and servers that contain spyware, adware, and other malware. This may be achieved by adding entries for those sites to redirect requests to another address that is a dead-end or harmless destination. Often, the local (loopback) address is used for such purposes, but this may result in conflicts if local web services are installed.

Various software applications exist that populate the hosts file with entries of undesirable Internet resources automatically.

Security issues

Because of its central role in local host resolution, the hosts file represents an attack vector for malicious software. The file can be hijacked, for example, by adware, computer viruses, trojan horse software, and may be modified to redirect traffic from an intended destination to sites hosting content that may be offensive or intrusive to the user or the user’s computer system.[5] The widespread worm Mydoom.B blocked users from visiting sites regarding computer security and antivirus software and also affected users' ability to access the Windows Update website. Administrators can set the file permissions of the hosts file to read-only as a means to help defend against malicious redirects caused by malicious software editing the hosts file when casual users without permissions use the computer.

See also


External links


Got something to say? Make a comment.
Your name
Your email address