Caddyfile doesn't recognize pki global option

1. Caddy version (caddy version): v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=

2. How I run Caddy:

I run caddy by executing caddy run in my terminal window.

a. System environment:

AlmaLinux release 8.5

b. Command:

caddy run -adapter caddyfile -config Caddyfile

c. Service/unit/compose file: –

d. My complete Caddyfile:

  pki {


3. The problem I’m having:

When I run caddy run -adapter caddyfile -config Caddyfile, I get the error message stating that the pki global option is not recognized.

4. Error messages and/or full log output:

[user@host caddy-server]$ sudo caddy run
2022/04/05 09:53:02.434 INFO    using adjacent Caddyfile
run: adapting config using caddyfile: Caddyfile:3: unrecognized global option: pki

5. What I already tried:

When I run caddy using JSON config instead of Caddyfile, Caddy recognizes the pki app and runs perfectly well. Example JSON config I tested this with:

  "apps" {
    "pki": { }

6. Links to relevant resources: –

You’re so close! Lose the top-level braces and it will work just fine.

pki {


When you had those braces, it was trying to interpret pki as a global option rather than a block. The docs have a great visual Caddyfile structure image for reference.

EDIT: Ignore. I read logs too fast before my coffee

Oh snap! For some reason I thought that pki is a global option… Tyvm!

Hm. But the documentation says that pki is indeed a global option. If I omit the top-level braces it interprets pki as a domain name
And the source code tells me that there should be an option like that, because it’s added at init: link

Though for 2.4.6 version there’s no global option registration at init…
I was able to fix my issue by updating to 2.5.0-beta.1

Yep – the PKI app was only added after v2.4.6.

Glad you figured it out :+1:

1 Like

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