It’s a system file that defines manual IP resolving for specified domains. If you have a pair of IP and domain name in your hosts file, then your browser won’t rely on DNS resolving for that domain name and will send all requests to given IP.

Hosts file example:

This means, that when you try to open any page at or, all requests will go to your localhost –

Windows hosts file

It’s located on your system drive (in most cases it’s “C:\”), so the full path to that file will be:


Mac OS hosts file path

In Mac OS X, the this file is placed in


but for compatibility, it’s also symlinked to


In Linux/Unix systems:

it’s located in

/etc/hosts as well.

Editing hosts file

Any text editor of your choice should be sufficient to edit the hosts file, as it’s a simple plain text file.

The structure of the file is simple:

first goes the IP address, second is the domain – one ore more, they just have to be placed in one line after the IP address, and can be separated by tab, one or more spaces

All these records will work: www.test.local

One thing to remember – if you have more than one occurrence of the same domain linked to different addresses, only the latter one will be applied in your system. So, if you’ll put something like this into your hosts file: 

when you’ll try opening, your browser will send a request to, as it was the last IP referring to that domain in the hosts file.