We have a Debian 8.2 system foo provided by our IT department for production. Its /etc/hosts file contains these two lines:       localhost       foo.example.com   foo

This maps the FQDN of the system to, while the real IP address of the system is (which is not given in hosts).

Is this correct or should /etc/hosts not contain the FQDN?

Note that the system is networked, has access to DNS and nslookup with the FQDN gives the correct IP address (

closed as primarily opinion-based by Thomas Dickey, Jakuje, Anthon, Stephen Kitt, Archemar Feb 15 '16 at 12:57

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • This has been discussed before, but overall, answers here are largely opinion-based. – Thomas Dickey Feb 15 '16 at 11:11
  • 2
    As I said in my answer, I have already seen real world problems due to this practice - this is more than an opinion. While it can be used in testing environments, I do not recommend using it in production environments. Cheers – Rui F Ribeiro Feb 15 '16 at 11:15
  • Is the second IP intended to be .0.1? – Jeff Schaller Feb 15 '16 at 11:31
  • @JeffSchaller: No. It really is .1.1. – Martin Schröder Feb 15 '16 at 12:26
  • 1
    @ThomasDickey: I'm looking for best practice here. – Martin Schröder Feb 15 '16 at 12:30

I regard this as a bad practice, I have seen developers doing that. While it can be used in testing environments, I do not recommend using it in production environments.

By definition, the kernel has a very defined behaviour for the localhost.

There could be also problems too, I do remember having a service opened to the Internet that was not working, because the developer used the name in a config file, that was pointing to the loopback instead of the public address.

I my opinion your hosts files should be:       localhost       foo.example.com   foo
  • 1
    The OP's question had the fqdn on, not – Stéphane Chazelas Feb 15 '16 at 15:36
  • Indeed thanks. This question is on track to be closed nonetheless. Corrected it. – Rui F Ribeiro Feb 15 '16 at 15:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.