Caddy gives errors on the most basic Caddyfile?

1. The problem I’m having:

Cant start a caddy server. Caddy fmt keeps telling me there is an error with the the caddy file

2. Error messages and/or full log output:

2023/07/01 15:30:31.662 INFO    using adjacent Caddyfile
2023/07/01 15:30:31.664 WARN    Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies    {"adapter": "caddyfile", "file": "Caddyfile", "line": 2}
Error: Caddyfile:2: Caddyfile input is not formatted

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:

installed it from the docs - the latest stable version

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

a. System environment:

Ubuntu 22.04, not docker

b. Command:

systemctl start caddy 
sudo caddy reload 

Second command to format the file

caddy fmt

c. Service/unit/compose file:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

d. My complete Caddy config:

indrajeethaldar.com {
        respond "Foo!"
}

5. Links to relevant resources:

None really im super confused because this was working last night?

It’s still working. It’s not an error. It’s a warning. Yeu probably have spaces instead of tabs in the second line. Run

caddy fmt --overwrite

to resolve the cause of the warning. Anyways, nothing is blocking running the server.

1 Like

Hi so i tried that and it seems to run - but I see a blank page on the domain instead of “Foo”

I also tried running the actual website code

indrajeethaldar.com {
	root * /home/indrajeet/portfolio
	file_server
}

and despite there being an index file there it seems to be giving me a blank page

/portfolio$ ls
about.html              index.html           all.html       data                    Projects                images

Okay so I’ve fixed this for me. The issue was that caddy wasnt using the correct config file. To be sure use the command (Even if you are in the same directory as the Caddyfile)

sudo caddy start --config Caddyfile

Using --config Caddyfile isn’t necessary. It is the same as the default without specifying --config.

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