dnslocalhostsubdomain

It is safe to use lvh.me instead of localhost for testing?


I wonder whether is safe to use lvh.me instead of localhost when developing locally, since lvh.me must be resolved and the IP may change over time.

The goal of using lvh.me is to be able to handle subdomains, since localhost does not have top level domain.


Solution

  • Unless you are the maintainer of lvh.me, you can not be sure it will not disappear or change its RRs for lvh.me.

    You can use localhost.localdomain instead of localhost, by adding the following lines in your hosts file:

    127.0.0.1 localhost localhost.localdomain
    ::1 localhost localhost.localdomain
    

    This is better than using lvh.me because:

    Since you said in a comment that you do not want to update the host file, you have no mean to be sure that lvh.me will always work for your developers. Therefore, to answer your question: it is not safe. You may register a domain for yourself, but as I said before, some resolvers will block answers corresponding to private addresses space.