Error: reading default Caddyfile: open Caddyfile: permission denied

Very first try with Caddy.
Installed as a snap on Lubuntu 24.04
I’m following the Quick Start instructions at Caddyfile Quick-start

1. The problem I’m having:

As per the instructions, I have created /home/alan/DEV/caddy/Caddyfile
Caddyfile contains only this:

{
        debug
}

localhost

respond "Hello, world!"

I get an error message when I run $ sudo caddy start while inside /home/alan/DEV/caddy/

2. Error messages and/or full log output:

$ sudo caddy start
+ id -u
+ [ 0 = 0 ]
+ _caddy=/snap/caddy/673/usr/bin/caddy
+ snapctl get modified
+ [  = true ]
+ cli start
+ arg=start
+ shift 1
+ /snap/caddy/673/usr/bin/caddy start
2025/11/26 19:22:00.948 WARN    failed to set GOMAXPROCS        {"error": "open /proc/self/mountinfo: permission denied"}
2025/11/26 19:22:00.948 INFO    GOMEMLIMIT is updated   {"package": "github.com/KimMachineGun/automemlimit/memlimit", "GOMEMLIMIT": 7679873433, "previous": 9223372036854775807}
2025/11/26 19:22:00.948 INFO    maxprocs: No GOMAXPROCS change to reset
Error: reading default Caddyfile: open Caddyfile: permission denied
Error: caddy process exited with error: exit status 1

journalctl -u caddy --no-pager | less +G
shows

– No entries –

3. Caddy version:

$ sudo caddy version
+ id -u
+ [ 0 = 0 ]
+ _caddy=/snap/caddy/673/usr/bin/caddy
+ snapctl get modified
+ [  = true ]
+ cli version
+ arg=version
+ shift 1
+ /snap/caddy/673/usr/bin/caddy version
551f793700fe1550845c824470b623fd1aa03d36 (22 Aug 25 21:29 UTC)

4. How I installed and ran Caddy:

a. System environment:

$ uname -a
Linux L24 6.14.0-33-generic #33~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 19 17:02:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
$ systemd --version
systemd 255 (255.4-1ubuntu8.11)
+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified 
$ snap --version
snap          2.72
snapd         2.72
series        16
ubuntu        24.04
kernel        6.14.0-33-generic
architecture  amd64

b. Command:

$ sudo caddy start

c. Service/unit/compose file:

d. My complete Caddy config:

{
        debug
}

localhost

respond "Hello, world!"
$ ll
total 12
drwxrwxr-x 2 alan alan 4096 Nov 26 19:21 ./
drwxrwxr-x 5 alan alan 4096 Nov 26 18:47 ../
-rw-rw-r-- 1 alan alan   47 Nov 26 19:21 Caddyfile

I have tried changing the permissions of Caddyfile to rwxrwxrwx, but it makes no difference.

5. Links to relevant resources:

Caddyfile Quick-start — Caddy Documentation

You have a snap version of Caddy installed, and snaps have limited permission to read files on your system. Don’t use the snap. That’s not an official installation method.

The quick start isn’t quite representative of how you should run Caddy normally, it’s more of a tour of Caddy. See Keep Caddy Running — Caddy Documentation.

3 Likes

Thank you, Francis

I have removed the snap and installed caddy from my apt repository.

Now I get a different error:

$ caddy start
2025/11/29 14:17:25.966 INFO    using adjacent Caddyfile
Error: loading initial config: loading new config: starting caddy administration endpoint: listen tcp 127.0.0.1:2019: bind: address already in use
Error: caddy process exited with error: exit status 1

I’m reading the docs…

You didn’t stop your other Caddy process. Also stop using caddy start, it doesn’t let you see logs. Run Caddy as a systemd service.

Thank you again, Francis

As a developer I was simply looking for a quick and easy way to get an https server up for testing.

I shall persevere for now, but perhaps ultimately I should look elsewhere…?

But it is quick and easy. Just follow the docs at the links I gave you. Uninstall the Caddy you got from snap, then install Caddy from our apt repo, then put your Caddyfile in /etc/caddy/Caddyfile, then reload the config with sudo systemctl reload caddy. That’s all you need to get up and running.

2 Likes

A final thank you, Francis, I’m almost there… :slightly_smiling_face:

1 Like

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