Hosts file

From TheAlmightyGuru
Jump to: navigation, search

A hosts file is a simple text file used by a computer to cross-reference an IP address with a URL before attempting to connect to a DNS server.

They exist on most operating systems with the same two fields separated by whitespace, first the IP address, then the replacement URL. For example:


The hosts file has many uses including:

  • Direct a URL to an IP address not listed in a DNS server. Some countries force DNS severs to remove URLs they find offensive and some companies exclude URLs from their local DNS servers to block Internet access for employees.
  • Reroute URLs to an IP address different from your DNS server. Useful if a server's IP address has changed, but the local DNS server has not yet been updated.
  • Block access to a particular URL. Security software like Spybot: Search & Destroy does this to protect users from harmful websites.


Here are examples of each of the following uses:

The following entry will direct someone trying to get to to the site's IP address, even if their country's DNS blocks the URL.

The following entry will redirect all traffic intended to go to to the IP address, which is the FBI's web site.

The following entry will block all traffic to by rerouting it to the local computer.


The hosts file is located in different locations for different operating systems.

Operating System Path
Android /system/etc/hosts
iOS /private/etc/hosts
Linux /etc/hosts
OS X /private/etc/hosts
Windows XP / Vista / 7 / 8 / 10 \windows\system32\drivers\etc\hosts
Windows NT / 2000 / 2003 / 2008 / 2012 \winnt\system32\drivers\etc\hosts