2

I have looked at the hosts file before but never thought of this. The hosts file overrides the DNS addresses so it can be used to forward sites or to block them.

When looking at the file, the default says this.

# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

What happens if remove or change the localhost configuration file? Would it prevent my Mac from booting. Would I be able to boot into recovery mode and revert the changes or would I have to reinstall the OS? If I had bootcamp would I be able to fix it by booting into Windows?

5
  • Won't prevent booting & as far as I'm aware localhost is more inherent to the system than just being listed in hosts, though unless you specifically need a loopback address I'd say you're unlikely to even notice. I would ask why you feel the need to remove it though.
    – Tetsujin
    Jun 10, 2015 at 14:00
  • I don't want to remove it. I just wanted to know what would happen if I did by accident. When I get my hard drive back (someone is borrowing it) I may backup my system and try it out. Also why does it say it is used during booting when it doesn't prevent booting?
    – iProgram
    Jun 10, 2015 at 14:04
  • @iProgram it says that it's used during booting because the operating system references the file during it's boot sequence, but it doesn't block the operating system from booting. Editing (adding to) the file in general is fine. You don't need to reboot for changes to take effect, but I wouldn't recommend changing the 3 lines that are already there unless you're doing it for a decent reason :)
    – sofly
    Jun 10, 2015 at 15:41
  • @SoFLy So you mean the only thing it does at bootup is loading the host file itself?
    – iProgram
    Jun 10, 2015 at 15:55
  • 1
    @iProgram when the computer boots, the network starts up, and the information in the hosts file is used to start the network. So it's just a piece of the puzzle.
    – sofly
    Jun 10, 2015 at 15:59

1 Answer 1

2

the only difference is that in order to access local web servers (for development purposes) you will need to use the address 127.0.0.1 instead of localhost.

3
  • So it is just like a normal DNS entry then? So I will not becloud to use localhost then?
    – iProgram
    Jun 10, 2015 at 14:39
  • the hosts file is the local equivalent to a DNS server. If it is missing then you can't type localhost in your browser and expect it to work, but IP still works and remains uneffected. Just like Benyamin said. Jun 10, 2015 at 15:44
  • I have worked in networks where someone "accidentally" configured DNS so that the name "localhost" would resolve to a remote machine for malicious purposes.
    – Don Simon
    Jun 10, 2015 at 18:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .