Show error page if ask directive of on_demand_tls fails

1. The problem I’m having:

I am using the ask directive of on_demand_tls. If a particular domain doesn’t exist, right now it shows “url sent an invalid response, ERR_SSL_PROTOCOL_ERROR”. Is there a way to show a html page instead of this?

2. Error messages and/or full log output:


3. Caddy version:


a. System environment:

Ubuntu 22.04

b. Command:


c. Service/unit/compose file:


d. My complete Caddy config:


5. Links to relevant resources:


That’s impossible. If the TLS handshake fails, the client can’t trust anything coming from the server, so you’ll only ever be able to see the browser’s own error messages.

1 Like

And to be clear, this is just how the Web works – not a limitation of Caddy, per-se. Browsers won’t even establish a secure connection without a valid certificate, so there’s no way to send an HTML response back.

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