Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

curl gets tlsv1 alert internal error from a Caddy site

Your error

error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error2 more lines it can show

Fix it fast

Most common cause, 1 of 3

The requested name is not a site address in the Caddyfile

Add every host name you serve to the site address, comma separated.

Fix
{
    default_sni example.com
}

example.com, www.example.com {
    reverse_proxy 127.0.0.1:3000
}
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

curl error 14094438 (0A000438 in OpenSSL 3), tlsv1 alert internal error, means Caddy's certificate lookup failed for the host name in the handshake. The Go TLS stack inside Caddy 2 answers that failure with TLS alert 80. Add the name to the Caddyfile site address, let the ACME challenge succeed, or remove auto_https off and load a certificate.

  • Applies to Caddy 2.11, OpenSSL 3.0 to 4.1, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Handshake with the server's address while sending each host name you serve, then read Caddy's own log. Caddy writes TLS handshake errors at debug level only, so add debug to the global options block and reload before you look. The name that fails in s_client is the one the log complains about.

Run this first
openssl s_client -connect 203.0.113.10:443 -servername www.example.com -brief </dev/null
# Caddyfile, first block:  { debug }
sudo systemctl reload caddy
journalctl -u caddy --no-pager | grep "TLS handshake error" | tail -n 5

Then find the line you see in this list and open its fix:

  1. 1The requested name is not a site address in the Caddyfileno certificate available for 'www.example.com' (or for an IP address) while the bare domain works
  2. 2Issuance for the name has not succeeded yetThe name is configured, but the log shows challenge failures or retries and never an obtained certificate
  3. 3auto_https turns certificate management off and no certificate is loadedEvery HTTPS name fails, and the global options contain auto_https off or auto_https disable_certs

What does the error look like?

  • error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error
  • error:0A000438:SSL routines::tlsv1 alert internal error
  • http: TLS handshake error from 198.51.100.7:52114: no certificate available for 'www.example.com'

Cause 1 of 3

The requested name is not a site address in the Caddyfile

You seeno certificate available for 'www.example.com' (or for an IP address) while the bare domain works

Check

The tlsv1 alert internal error appears when the name in the ClientHello matches no site address, so Caddy has no certificate to pick. CertMagic then returns its no-certificate error, and Go's TLS server answers every certificate lookup error except its own empty-list case with alert 80. A client that sends no name at all is matched against default_sni if set, otherwise against the local IP of the connection.

Check
grep -n -E "^[^ #].*\{" /etc/caddy/Caddyfile
openssl s_client -connect 203.0.113.10:443 -noservername -brief </dev/null

Fix

Add every host name you serve to the site address, comma separated. If old clients or health checks connect without SNI, name the domain they should get in the default_sni global option.

Fix
{
    default_sni example.com
}

example.com, www.example.com {
    reverse_proxy 127.0.0.1:3000
}

Verify

Reload, then repeat the handshake for each name; every one prints a protocol and cipher line instead of an alert.

Verify
sudo systemctl reload caddy
openssl s_client -connect 203.0.113.10:443 -servername www.example.com -brief </dev/null

Confirmed by caddyserver.com

Did this fix it?

Cause 2 of 3

Issuance for the name has not succeeded yet

You seeThe name is configured, but the log shows challenge failures or retries and never an obtained certificate

Check

The internal error alert also appears for a configured name while Caddy is still failing to obtain its first certificate. Caddy's docs list what the ACME challenge needs: A and AAAA records that point at this machine, ports 80 and 443 open from the internet, permission to bind them, and a data directory that is writable and kept between restarts. After repeated failures it waits longer each time, up to one day between attempts.

Check
journalctl -u caddy --no-pager | less +G
sudo ss -ltnp | grep -E ':(80|443) '

Fix

Repair the condition the log names: correct the DNS record, open or forward both ports, stop the other web server that holds them, or give Caddy a persistent, writable data folder. Restart so it tries again at once instead of waiting out the backoff.

Fix
sudo systemctl restart caddy

Verify

The log reports the certificate as obtained, and the s_client handshake for that name completes.

Verify
journalctl -u caddy --no-pager | tail -n 30
openssl s_client -connect www.example.com:443 -servername www.example.com -brief </dev/null

Confirmed by caddyserver.com

Did this fix it?

Cause 3 of 3

auto_https turns certificate management off and no certificate is loaded

You seeEvery HTTPS name fails, and the global options contain auto_https off or auto_https disable_certs

Check

When every name gets tlsv1 alert internal error, look for auto_https in the global options. auto_https off stops both certificate automation and the HTTP to HTTPS redirects, while disable_certs stops only the automation. Either way, a site with no manually loaded certificate has nothing to present.

Check
grep -n -E 'auto_https|tls ' /etc/caddy/Caddyfile

Fix

Delete the auto_https line so Caddy manages certificates again, or point the tls directive at your own certificate and key. The directive needs both paths; one alone is invalid.

Fix
example.com {
    tls /etc/ssl/example.com.crt /etc/ssl/example.com.key
    reverse_proxy 127.0.0.1:3000
}

Verify

Reload Caddy and run the handshake once more.

Verify
sudo systemctl reload caddy
openssl s_client -connect example.com:443 -servername example.com -brief </dev/null

Confirmed by caddyserver.com

Did this fix it?

How do I stop it coming back?

  • Add a subdomain to the Caddyfile before its DNS record starts sending traffic to the server.
  • Probe each new name with openssl s_client and -servername before announcing it.
  • Mount Caddy's data directory on persistent storage in containers, so issued certificates outlive a redeploy.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.