Error reading caddyfile if use -config parameter

1. Caddy version (caddy version):


2. How I run Caddy:

a. System environment:

Win10 x64 v21H1

b. Command:

caddy_windows_amd64.exe run -config "caddyfile"

c. Service/unit/compose file:

d. My complete Caddyfile or JSON config: {
	reverse_proxy :81

3. The problem I’m having:

This looks like a bug to me, but wanted to make sure I wasn’t missing something.
If I don’t use the -config param, the caddyfile is used and there is no problem, but if I use the -config param, Caddy complains about the first character in the file, a “w”, and drops out.

4. Error messages and/or full log output:

INFO using provided configuration {“config_file”: “caddyfile”, “config_adapter”: “”}
run: loading initial config: decoding request body: invalid character ‘w’ looking for beginning of value

5. What I already tried:

Quote symbols around the filename don’t change anything.

6. Links to relevant resources:

Are you sure the file is named caddyfile, or is it Caddyfile? It should be Caddyfile.

I think what’s going on is Caddy will only assume the adapter to be caddyfile is the filename begins with Caddyfile (case sensitive). Otherwise, it assumes it’s a JSON config. So it reads the first character, sees it’s not a valid JSON character, and quits.

So you’d need to use the --adapter caddyfile flag to tell it “this is a Caddyfile, actually” and make it not assume it’s JSON. Or just make sure your file is named Caddyfile with an uppercase C.


Yep, uppercase Caddyfile, just like Dockerfile used to require.

You hit it. I don’t even need to change the filename on disk, just change the CLI param to have a capital C and it works. Thanks!


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