Ubuntu 24.04 New Installation Failures

1. The problem I’m having:

Having followed the installation instructions for Ubuntu, I installed Caddy on a fresh Ubuntu 24.04 installation. Ubuntu had all it’s updates done before I installed Caddy.

During install there is an error which states “Could not execute systemctl: at /usr/bin/deb-systemd-invoke line 148.”

After this, I try to run “systemctl status caddy” and it does not work and gives the following error:

Job for caddy.service failed because the control process exited with error code.
See “systemctl status caddy.service” and “journalctl -xeu caddy.service” for details.

Any assistance would be most appreciated.

2. Error messages and/or full log output:

journalctl -xeu caddy.service output is as follows:

░░ The job identifier is 36285.
Mar 18 13:27:21 EQ12 systemd[1]: caddy.service: Main process exited, code=exite>
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStart= process belonging to unit caddy.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 203.
Mar 18 13:27:21 EQ12 systemd[1]: caddy.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: ubuntu support url was here and had to be removed
░░ 
░░ The unit caddy.service has entered the 'failed' state with result 'exit-code>
Mar 18 13:27:21 EQ12 systemd[1]: Failed to start caddy.service - Caddy.
░░ Subject: A start job for unit caddy.service has failed
░░ Defined-By: systemd
░░ Support: ubuntu support url was here and had to be removed
░░ 
░░ A start job for unit caddy.service has finished with a failure.
░░ 
░░ The job identifier is 36285 and the job result is failed.
lines 338-360/360 (END)
░░ The job identifier is 36285.
Mar 18 13:27:21 EQ12 systemd[1]: caddy.service: Main process exited, code=exited, status=203/EXEC
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: ubuntu support url was here and had to be removed
░░ 
░░ An ExecStart= process belonging to unit caddy.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 203.
Mar 18 13:27:21 EQ12 systemd[1]: caddy.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: ubuntu support url was here and had to be removed
░░ 
░░ The unit caddy.service has entered the 'failed' state with result 'exit-code'.
Mar 18 13:27:21 EQ12 systemd[1]: Failed to start caddy.service - Caddy.
░░ Subject: A start job for unit caddy.service has failed
░░ Defined-By: systemd
░░ Support: ubuntu support url was here and had to be removed
░░ 
░░ A start job for unit caddy.service has finished with a failure.
░░ 
░░ The job identifier is 36285 and the job result is failed.
(then there's a bunch of these '~' symbols, which I've removed for now)
lines 338-360/360 (END)
░░ The job identifier is 36285.
Mar 18 13:27:21 EQ12 systemd[1]: caddy.service: Main process exited, code=exited, status=203/EXEC
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: ubuntu support url was here and had to be removed
░░ 
░░ An ExecStart= process belonging to unit caddy.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 203.
Mar 18 13:27:21 EQ12 systemd[1]: caddy.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: ubuntu support url was here and had to be removed
░░ 
░░ The unit caddy.service has entered the 'failed' state with result 'exit-code'.
Mar 18 13:27:21 EQ12 systemd[1]: Failed to start caddy.service - Caddy.
░░ Subject: A start job for unit caddy.service has failed
░░ Defined-By: systemd
░░ Support: ubuntu support url was here and had to be removed
░░ 
░░ A start job for unit caddy.service has finished with a failure.
░░ 
░░ The job identifier is 36285 and the job result is failed.

Output of journalctl -u caddy --no-pager | less +G

Mar 17 19:23:08 EQ12 systemd[1]: Starting caddy.service - Caddy...
Mar 17 19:23:08 EQ12 caddy[497948]: caddy.HomeDir=/var/lib/caddy
Mar 17 19:23:08 EQ12 caddy[497948]: caddy.AppDataDir=/var/lib/caddy/.local/share/caddy
Mar 17 19:23:08 EQ12 caddy[497948]: caddy.AppConfigDir=/var/lib/caddy/.config/caddy
Mar 17 19:23:08 EQ12 caddy[497948]: caddy.ConfigAutosavePath=/var/lib/caddy/.config/caddy/autosave.json
Mar 17 19:23:08 EQ12 caddy[497948]: caddy.Version=2.6.2
Mar 17 19:23:08 EQ12 caddy[497948]: runtime.GOOS=linux
Mar 17 19:23:08 EQ12 caddy[497948]: runtime.GOARCH=amd64
Mar 17 19:23:08 EQ12 caddy[497948]: runtime.Compiler=gc
Mar 17 19:23:08 EQ12 caddy[497948]: runtime.NumCPU=4
Mar 17 19:23:08 EQ12 caddy[497948]: runtime.GOMAXPROCS=4
Mar 17 19:23:08 EQ12 caddy[497948]: runtime.Version=go1.22.2
Mar 17 19:23:08 EQ12 caddy[497948]: os.Getwd=/
Mar 17 19:23:08 EQ12 caddy[497948]: LANG=en_US.UTF-8
Mar 17 19:23:08 EQ12 caddy[497948]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/snap/bin
Mar 17 19:23:08 EQ12 caddy[497948]: XDG_DATA_DIRS=/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/
Mar 17 19:23:08 EQ12 caddy[497948]: NOTIFY_SOCKET=/run/systemd/notify
Mar 17 19:23:08 EQ12 caddy[497948]: USER=caddy
Mar 17 19:23:08 EQ12 caddy[497948]: LOGNAME=caddy
Mar 17 19:23:08 EQ12 caddy[497948]: HOME=/var/lib/caddy
Mar 17 19:23:08 EQ12 caddy[497948]: INVOCATION_ID=6a0c90ff9f2a4424810810a203175952
Mar 17 19:23:08 EQ12 caddy[497948]: JOURNAL_STREAM=9:1745068
Mar 17 19:23:08 EQ12 caddy[497948]: SYSTEMD_EXEC_PID=497948
Mar 17 19:23:08 EQ12 caddy[497948]: MEMORY_PRESSURE_WATCH=/sys/fs/cgroup/system.slice/caddy.service/memory.pressure
Mar 17 19:23:08 EQ12 caddy[497948]: MEMORY_PRESSURE_WRITE=c29tZSAyMDAwMDAgMjAwMDAwMAA=
Mar 17 19:23:08 EQ12 caddy[497948]: {"level":"info","ts":1742239388.7591238,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Mar 17 19:23:08 EQ12 caddy[497948]: {"level":"info","ts":1742239388.7602196,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
Mar 17 19:23:08 EQ12 caddy[497948]: {"level":"warn","ts":1742239388.760326,"logger":"http","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
Mar 17 19:23:08 EQ12 caddy[497948]: {"level":"info","ts":1742239388.7604096,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00021a150"}
Mar 17 19:23:08 EQ12 caddy[497948]: {"level":"info","ts":1742239388.7604454,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/var/lib/caddy/.local/share/caddy"}
Mar 17 19:23:08 EQ12 caddy[497948]: {"level":"info","ts":1742239388.7604697,"logger":"tls","msg":"finished cleaning storage units"}
Mar 17 19:23:08 EQ12 caddy[497948]: {"level":"info","ts":1742239388.7604897,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
Mar 17 19:23:08 EQ12 caddy[497948]: {"level":"info","ts":1742239388.760618,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Mar 17 19:23:08 EQ12 caddy[497948]: {"level":"info","ts":1742239388.7606528,"msg":"serving initial configuration"}
Mar 17 19:23:08 EQ12 systemd[1]: Started caddy.service - Caddy.
Mar 17 19:24:27 EQ12 systemd[1]: Stopping caddy.service - Caddy...
Mar 17 19:24:27 EQ12 caddy[497948]: {"level":"info","ts":1742239467.1537342,"msg":"shutting down apps, then terminating","signal":"SIGTERM"}
Mar 17 19:24:27 EQ12 caddy[497948]: {"level":"warn","ts":1742239467.153863,"msg":"exiting; byeee!! 👋","signal":"SIGTERM"}
Mar 17 19:24:27 EQ12 caddy[497948]: {"level":"info","ts":1742239467.1540713,"logger":"tls.cache.maintenance","msg":"stopped background certificate maintenance","cache":"0xc00021a150"}
Mar 17 19:24:27 EQ12 caddy[497948]: {"level":"info","ts":1742239467.154159,"logger":"admin","msg":"stopped previous server","address":"localhost:2019"}
:

3. Caddy version:

4. How I installed and ran Caddy:

Install — Caddy Documentation - I followed these instructions.

a. System environment:

Ubuntu 24.04, EQ12 Mini PC, Intel N100 CPU, Caddy installed via the Ubuntu instructions (systemd).

b. Command:

systemctl status caddy

c. Service/unit/compose file:

I haven't gotten as far as making one of these yet :(.

d. My complete Caddy config:

I haven't gotten as far as making one of these yet :(.

5. Links to relevant resources:

This appears to be an issue with Ubuntu

I’m not really sure how to solve the problem with this. From the thread you linked I ran:

sudo nano /var/lib/dpkg/info/caddy.postinst and I got this output:

#!/bin/sh
set -e

if [ "$1" = "configure" ]; then
        # Add user and group
        if ! getent group caddy >/dev/null; then
                groupadd --system caddy
        fi
        if ! getent passwd caddy >/dev/null; then
                useradd --system \
                        --gid caddy \
                        --create-home \
                        --home-dir /var/lib/caddy \
                        --shell /usr/sbin/nologin \
                        --comment "Caddy web server" \
                        caddy
        fi
        if getent group www-data >/dev/null; then
                usermod -aG www-data caddy
        fi

        # handle cases where package was installed and then purged;
        # user and group will still exist but with no home dir
        if [ ! -d /var/lib/caddy ]; then
                mkdir -p /var/lib/caddy
                chown caddy:caddy /var/lib/caddy
        fi

        # Add log directory with correct permissions
        if [ ! -d /var/log/caddy ]; then
                mkdir -p /var/log/caddy
                chown caddy:caddy /var/log/caddy
        fi
fi

if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
        # This will only remove masks created by d-s-h on package removal.
        deb-systemd-helper unmask caddy.service >/dev/null || true
        deb-systemd-helper unmask caddy-api.service >/dev/null || true

Is everyone who has installed Caddy on Ubuntu since over a year ago, editing this file to install it correctly?

I’m not sure which lines I need to mess with or how to do it correctly without breaking something.

If anyone can provide any further guidance, I would be most appreciative.

So I figured out the problem. I tried installing Debian 12 and had the same issue, but the error message was slightly different, and It led me to find that because I’d accidentally ticked “web server” during the install which installed apache, so port 80 was occupied and caddy couldn’t do it’s thing.

Uninstalled apache, now it works.

1 Like