Systemctl status caddy says running caddy has failed

1. Caddy version (caddy version):

Version 2.4.6

2. How I run Caddy:

caddy start
systemctl start caddy

Frankly it’s not clear to me if best practice for managing a live caddy server is best done with

caddy stop
caddy start
caddy reload

systemctl stop caddy
systemctl start caddy
systemctl restart caddy

a. System environment:

Debian 11

b. Command:

root@ssdnodes-65240:/var/log/caddy# ps -aux | grep caddy
caddy     366776  0.0  0.1 306132 26444 ?        S    17:03   0:00 php-fpm: pool www
caddy     366777  0.0  0.1 231588 25720 ?        S    17:03   0:00 php-fpm: pool www
root      371599  0.0  0.2 738700 43028 pts/0    Sl   20:21   0:00 caddy run --pingback
root      372146  0.0  0.0   6204   664 pts/0    S+   21:06   0:00 grep caddy

root@ssdnodes-65240:/var/log/caddy# systemctl status caddy
● caddy.service - Caddy
     Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-01-20 20:52:21 UTC; 15min ago
    Process: 371933 ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile (code=exited, status=1/FAILURE)
   Main PID: 371933 (code=exited, status=1/FAILURE)
        CPU: 71ms

Jan 20 20:52:21 ssdnodes-65240 caddy[371933]: HOME=/var/lib/caddy
Jan 20 20:52:21 ssdnodes-65240 caddy[371933]: LOGNAME=caddy
Jan 20 20:52:21 ssdnodes-65240 caddy[371933]: USER=caddy
Jan 20 20:52:21 ssdnodes-65240 caddy[371933]: INVOCATION_ID=5938f58462bf4894820155e1905fcd6a
Jan 20 20:52:21 ssdnodes-65240 caddy[371933]: JOURNAL_STREAM=8:3439508
Jan 20 20:52:21 ssdnodes-65240 caddy[371933]: {"level":"info","ts":1642711941.5401554,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","con>
Jan 20 20:52:21 ssdnodes-65240 systemd[1]: Started Caddy.
Jan 20 20:52:21 ssdnodes-65240 caddy[371933]: run: loading initial config: loading new config: starting caddy administration endpoint: listen tcp bi>
Jan 20 20:52:21 ssdnodes-65240 systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Jan 20 20:52:21 ssdnodes-65240 systemd[1]: caddy.service: Failed with result 'exit-code'.

d. My complete Caddyfile or JSON config:

# Set up global options
} {
	# Set this path to your site's directory.
	root * /var/www/lists

	# Set up logging
	log {
		output file /var/log/caddy/ {
			roll_size 3MiB
			roll_keep 5
			roll_keep_for 48h
		format console

	# Set up compression
	encode gzip zstd

	# Set up PHP FastCGI
	php_fastcgi unix//run/php/php8.1-fpm.sock

	# Set up TLS Protocols
	tls {
		protocols tls1.2 tls1.3

	# Enable static file server

	# Set up reverse proxy
	#   reverse_proxy localhost:8080

3. The problem I’m having:

Am trying to understand how best to consistently start/stop/reload/restart a Caddy instance and whether Caddy will automatically handle associated php-fpm processes, or whether I need to manually start/stop/restart them everytime I change my Caddyfile configuration.

Am also wondering if setting the DEBUG option in my Caddyfile might change either Caddy or Systemd’s stop/start/restart/reload behavior.

4. Error messages and/or full log output:

5. What I already tried:

6. Links to relevant resources:

Not those.

Yes, use these.

The error there is because you have an instance of Caddy already running from caddy start so the systemd service isn’t able to bind to port 2019 to start the admin endpoint. Make sure to kill off any instances before running systemctl start caddy again.

Those are already the defaults. I strongly recommend removing this from your config. Caddy’s defaults are modern and secure. If you specify the defaults explicitly in your config, then you’re making it harder for Caddy to improve security in future updates, if Caddy changes the defaults to something better later (for example in theory if a TLS 1.4 is introduced, your config would prevent Caddy from using it).

1 Like

Belated thanks!
And yes, your suggestion to let Caddy establish TLS automatically and NOT designate security automatically makes a lot of sense.
After all - the reason I’m learning and migrating to Caddy is to ruthlessly simplify my life AND configuration files :grinning:


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