Caddy is using the wrong Caddyfile (?)

1. The problem I’m having:

After restarting my VPS many times yesterday something broke: Caddy is not using the Caddyfile. By sheer chance I have found the solution here: Caddy gives errors on the most basic Caddyfile? - #4 by range-et

My question is, where can I specify for Caddy to use my Caddyfile? I have mine inside /home/username/ , it used to work in the past. Now I am lost. Caddy as a service also no longer starts when rebooting according to sudo systemctl caddy status. Not sure why. But when I start the service, or reload it with systemctl, it still does not load my Caddyfile, i have to specifically start with sudo caddy start --config Caddyfile

I doubt it’s the formatting of my Caddyfile, I did run ‘caddy fmt --overwrite’ on it like 20 times.

2. Error messages and/or full log output:

This is the error when I am not using my Caddyfile:
{“level”:“warn”,“ts”:1709384989.7451005,“msg”:"Caddyfile input is not formatted; run ‘caddy fmt --overwrite’ to fix inconsi…
{“level”:“warn”,“ts”:1709384989.7707202,“logger”:“http.auto_https”,“msg”:"server is listening only on the HTTP port, so no a…

3. Caddy version:

v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=
(installed on ubuntu according to docs)

4. How I installed and ran Caddy:

I installed (and re-installed just now) it according to docs on Ubuntu. Install — Caddy Documentation

b. Command:

I type no commands, in the past Caddy would start by itself.

d. My complete Caddy config:

# Set the email address that should be used to contact you if there is a problem with
# your TLS certificates.
# Run `caddy fmt --overwrite` to format this file
} {
	respond /debug/* "Not Permitted" 403

5. Links to relevant resources:

Here’s your problem. The service reads the configuration file from /etc/caddy/. There’s a Caddyfile inside that directory. You should use that directory.

1 Like


my user didn’t not have /etc/caddy, but the root user did. Not sure why or how it has worked up until now for half a year. Should I adjust my deployment script to have the root@ip upload Caddyfile, or do I have something funny happening here? My knowledge is very limited.

Thank you for such a fast help. Now the server seems to start automatically too.

You don’t have to use the root@ip. The user access, groups, and file permissions should be adjusted accordingly.

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