Manually run works, systemctl start not work

1. Caddy version (caddy version):

$ caddy version
v2.4.0-beta.1 h1:Ed/tIaN3p6z8M3pEiXWJL/T8JmCqV62FrSJCHKquW/I=

2. How I run Caddy:

$ cat /etc/caddy/Caddyfile
:8989 {
root * /srv/www/report
file_server
}

domain

192.168.0.133:8989

a. System environment:

$ uname -a
Linux work1 5.4.0-70-generic #78-Ubuntu SMP Fri Mar 19 13:29:52 UTC 2021 x86_64 GNU/Linux

b. Command:

# did not work
sudo systemctl start caddy
# command from caddy.service worked
sudo /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile

c. Service/unit/compose file:

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

[Service]
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:

:8989 {
        root * /srv/www/report
        file_server
}

3. The problem I’m having:

manually run works, I can visit my site
systemctl start not work, I can not visit

4. Error messages and/or full log output:

no error

5. What I already tried:

try manually, not using systemctl

6. Links to relevant resources:

guess it’s the service file problem

After=network.target network-online.target
Requires=network-online.target

What do you mean by “not work”? What’s in the logs?

Did you check that the caddy user has permissions to access those files?

1 Like

Thanks! It’s caddy permission problem.

1 Like

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