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

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:

  • you may not always have access to a DNS resolver, when developing
  • lvm.me does not answer with a local IPv6 address corresponding to your local host, only with the IPv4 address 127.0.0.1
  • some ISPs DNS resolvers block answers corresponding to private addresses space, for security purpose (to avoid leaking internal informations)

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.


lvh.me was not resolving to 127.0.0.1 on June 7, 2021. Depending on DNS names you don't control comes with this kind of risk. Although the domain name was reinstated by the end of the day, this answer offers some alternatives to depending on someone else's DNS configurations.

Both Firefox and Google Chrome now treat *.localhost names like localhost. They also do the right thing with port numbers.

To test it yourself, start a local http server listening to port 8000:

python -m http.server 8000

Then try these links

  • http://example.localhost:8000
  • http://other.localhost:8000
  • http://sub.subdomain.localhost:8000

This trick does not help for command line programs. For example, this command will fail to resolve the host:

curl http://example.localhost:8000

Curl itself offers a lot of other tricks that might work for you if you need custom subdomains on the command line. For example, this trick works:

curl --resolve example.localhost:127.0.0.1 \
  http://example.localhost:8000

Also worth noting that a similar service is still available.

See https://readme.localtest.me.

One last alternative is to configure your own wildcard CNAME to resolve to 127.0.0.1. For example:

*.my.example.com.   1800    IN  CNAME   my.example.com.
my.example.com.     1800    IN  A       127.0.0.1