Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add this entry:       api.localhost

To test the api of my web app.

However, the hosts file says:

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

Is it safe to add the entry I want to add? Can things go wrong?

share|improve this question
Fedora maps the hostname given at install time to under certain circumstances. If I'm not mistaking it happens when you have an Ethernet card, but no network connectivity, e.g. DHCP is not working. – Cristian Ciupitu Feb 6 '11 at 15:47
up vote 10 down vote accepted

The "do not change" warning refers to changing the name "localhost". Many software packages expect "localhost" to resolve to

Adding more entries is not a problem. You can add the entries after the host (as shown by Iain), or add additional lines. For example:   localhost   api.localhost   testsite2.localhost

On many UNIX-like systems, you can also use and so forth because the whole 127.*.*.* range is routed to the "local loopback device / driver".

share|improve this answer
Quoting from pRFC 5735 - "Special Use IPv4 Addresses"]( - This block is assigned for use as the Internet host loopback address. So any TCP/IP compliant system including Windows, Linux, MacOSX etc. should route 127.x.y.z addresses to the loopback. – Cristian Ciupitu Feb 7 '11 at 1:02

If your hosts file already contains a line for then all you have to do is add your api.localhost at the end of it e.g.               localhost api.localhost
share|improve this answer
It's perfectly safe, right? – rightfold Feb 6 '11 at 14:18
Yes :-) It's meant to do what you are doing ! – Antoine Benkemoun Feb 6 '11 at 15:17
Have a look at the macos man page for the hosts(5) file which says each line has IP address official hosts name aliases – Iain Feb 6 '11 at 15:19

Yup, this should be safe on any reasonable system. In fact, it's a common ad-blocking technique - for example, you can download premade hosts files filled with the names of common ad servers all pointed at

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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