Error on line 12, I have no idea what is wrong

1. The problem I’m having:

I installed Caddy 2.6.2 using apt-get, no plugins added. I added my static website to Caddyfile and it works great.
When I add another website using my local ip ( {root… …} and run ‘sudo caddy reload’ it gives an error and I have no idea the problem is.

2. Error messages and/or full log output:

The error I get when running 'sudo caddy reload is

2024/01/01 14:31:31.671 INFO    using adjacent Caddyfile
2024/01/01 14:31:31.676 WARN    Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies    {"adapter": "caddyfile", "file": "Caddyfile", "line": 12}

What is on line 12 is “root * /var/www/domain.tld/public_html” for my working static website.

3. Caddy version:

Caddy 2.6.2

4. How I installed and ran Caddy:

I installed Caddy using apt-get on Debian Bookworm

a. System environment:

Raspberry Pi 4
Debian 12 Bookworm
systemd 252 (252.19-1~deb12u1)

b. Command:

Caddy runs using systemd.
The command I run to get the error is

sudo caddy reload

sudo caddy fmt doesn’t fix anything

Please share the full Caddyfile. We can’t help without knowing what the file looks like with your changes.

Oh sorry, of course.

# The Caddyfile is an easy way to configure your Caddy web server.
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.

t*****.dev, www.t****.dev {
        root * /var/www/t*****.dev/public_html
        #php_fastcgi unix//run/php/php7.4-fpm.sock
        encode gzip
        #@disallowed {
        #    path /xmlrpc.php
        #    path *.sql
        #    path /wp-content/uploads/*.php
        #rewrite @disallowed '/index.php'
} {
        root * /var/www/html/admin
        php_fastcgi unix//run/php/php8.2-fpm.sock
        encode gzip
        #@disallowed {
        #    path /xmlrpc.php
        #    path *.sql
        #    path /wp-content/uploads/*.php
        #rewrite @disallowed '/index.php'

#:80 {
#       # Set this path to your site's directory.
#       root * /var/www/t****.dev/public_html/
#       # Enable the static file server.
#       file_server
#       # Another common task is to set up a reverse proxy:
#       # reverse_proxy localhost:8080
#       # Or serve a PHP site through php-fpm:
#       # php_fastcgi localhost:9000

# Refer to the Caddy docs for more information:

I’m trying to add a (temporary) url (ip address) for the pi-hole admin webpage.

The Caddyfile is fine. What you’re seeing is not an error, only a warning. You can fix it by running caddy fmt -w.

Oh, I thought it was an error. I got a little overwelmed with not knowing how to use Caddy. Thank you for the quick help.

I get Error: unknown shorthand flag: 'w' in -w when I try caddy fmt -w .

I ran caddy fmt --diff I removed the lines with a - so I have the formatted Caddyfile left. Still the same warning.

This is too old. Upgrade to v2.7.6 then run the command I gave you.

That did it! Thank you so much Mohammed90!
I didn’t realise the apt version was an older version. Now the warning is fixed thanks to caddy fmt -w, yay :grin:

1 Like

Please install Caddy using our official apt repo:

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