Caddy reload failing

1. Caddy version (caddy version):

v2.5.0-beta.1 h1:lF5wWqqDJ6HjETbnBILvTAeKcThsz1+OeWB+d1tWxp4=

2. How I run Caddy:

c. Service/unit/compose file:

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

d. My complete Caddyfile or JSON config:

{
        servers {
                protocol {
                        experimental_http3
                }
        }
}

azabache.narwhal-nominal.ts.net {
        reverse_proxy localhost:1080
}

chat.pinayalcachofa.es {
        reverse_proxy localhost:3000
}

3. The problem Iā€™m having:

sudo service caddy start and sudo service caddy stop work just fine, but if I try to reload the config file sudo service caddy reload I get an error Reload failed for Caddy.

This happens regardless I do changes on the config file or not.

4. Error messages and/or full log output:

Apr 02 10:51:01 azabache systemd[1]: Started Caddy.
Apr 02 10:51:46 azabache systemd[1]: Reloading Caddy.
Apr 02 10:51:47 azabache caddy[319012]: {"level":"info","ts":1648896707.0833464,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Apr 02 10:51:47 azabache caddy[319012]: {"level":"info","ts":1648896707.0862033,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Apr 02 10:51:47 azabache caddy[319012]: reload: sending configuration to instance: invalid admin address : missing port in address
Apr 02 10:51:47 azabache systemd[1]: caddy.service: Control process exited, code=exited, status=1/FAILURE
Apr 02 10:51:47 azabache systemd[1]: Reload failed for Caddy.

5. What I already tried:

Iā€™m not sure if this is relevant, but even though when I start caddy all works without issues, if I run caddy validate /etc/caddy/Caddyfile I get the following error:

validate: decoding config: unexpected end of JSON input

6. Links to relevant resources:

Thatā€™s not the right way to run that command, you should run:

caddy validate --config /etc/caddy/Caddyfile

As for why reloading isnā€™t workingā€¦ whoops, looks like I introduced a bug when making a change during a refactor to introduce a new feature. Iā€™ll fix it.

The issue is that the reload command is reading the config file and tries to get the admin address from the config, but it doesnā€™t fallback to the default if the address is empty (i.e. not explicitly specified), then it fails.

For now, you can restart Caddy completely with sudo service caddy restart, or explicitly put admin localhost:2019 in your Caddyfile (global options) to work around it for now.

Edit: Fixing it in this PR:

2 Likes

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