Confused about https cert generating for testing locally

The documentation seems to suggest that we could test Caddy locally, by adding an existing domain to /etc/hosts and then serving over caddy, but the certificate registration fails since the domain points to the real server IP.

Did I misunderstand what the documentation is suggesting, or am I doing something wrong?

For example, for which is currently hosted elsewhere, I have the following Caddyfile:

I get the following error:
sudo caddy
Activating privacy features…2016/06/23 15:46:35 [] failed to get certificate: acme: Error 400 - urn:acme:error:tls - Failed to connect to for TLS-SNI-01 challenge
Error Detail:
Validation for
Resolved to:


Obtaining a certificate and serving a site locally at a custom domain are two different things. You can use /etc/hosts to load your site over any hostname, for example, mytestsite or a real domain that exists elsewhere like, but you can’t use /etc/hosts to get a certificate for that name.

If you want to run a local dev site over HTTPS with any hostname you want, you should use tls self_signed (available in 0.9 beta).

1 Like

Thanks. I was a bit confused by the introduction, thinking I could get a cert for from the examples :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.