Error during parsing: Unable to load certificate and key files. No such file or directory

1. Caddy version (caddy version):

Caddy v1.0.3

2. How I run Caddy:

I have a droplet on DigitalOcean. On this droplet, I’m using systemctl to run a Rails application and caddy.

a. System environment:

Ubuntu 18.04.3 x64

b. Command:

I’m using this command in my caddy.service file:

ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp

c. Service/unit/compose file:

Description=Caddy HTTP/2 web server


; Letsencrypt-issued certificates will be written to this directory.

ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp
ExecReload=/bin/kill -USR1 $MAINPID



; The following additional security directives only work with systemd v229 or later.
; They further retrict privileges that can be gained by caddy. Uncomment if you like.
; Note that you may have to add capabilities required by any plugins in use.

d. My complete Caddyfile or JSON config: {
  tls /home/sammy/ /home/sammy/

  root /code/myblog


  proxy / http://localhost:5002 {

3. The problem I’m having:

I’m trying to use a certificate generated by Cloudflare instead of the ones generated by Caddy. I followed this guide:

I created the certificate and key files in the directory /home/sammy

However, when I try to start the caddy process:

systemctl start caddy.service

I get the following error (see next section).

4. Error messages and/or full log output:

Nov 06 14:58:24 ubuntu-s-1vcpu-1gb-ams3-01 systemd[1]: Started Caddy HTTP/2 web server.
Nov 06 14:58:25 ubuntu-s-1vcpu-1gb-ams3-01 caddy[770]: 2020/11/06 14:58:25 /etc/caddy/Caddyfile:26 - Error during parsing: Unable to load certificate and key files for '': open /home/sammy/ no such file or directory
Nov 06 14:58:25 ubuntu-s-1vcpu-1gb-ams3-01 systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Nov 06 14:58:25 ubuntu-s-1vcpu-1gb-ams3-01 systemd[1]: caddy.service: Failed with result 'exit-code'.

5. What I already tried:

I checked several times the paths and there’s no error. On this topic (What are the appropriate permissions for PEM files?) it’s written that chown root:www-data and chmod 640 are enough for caddy to open and work with the certificate and key but it still not working.

Here is the result of ls -l /home/sammy/

-rw-r----- 1 root www-data 1696 Nov  6 09:50
-rw-r----- 1 root www-data 1704 Nov  6 09:51

II always get the same error so I’m not sure what’s wrong.

I even tried to do open /home/sammy/ in my terminal and it doesn’t return me any error!


Caddy v1 is EOL, I strongly recommend upgrading to Caddy v2. Your usecase is very simple, so it shouldn’t take much effort.

In Caddy v2, the recommended systemd service installed by the debian package runs Caddy using the caddy user, so as long as the files are readable by that user, you should be good to go.

The home directory of the caddy user is /var/lib/caddy so you could but the certs and keys somewhere in there for Caddy to reach it.

I installed the latest Caddy and moved my certificate as well as the private key in a folder I created in /var/lib/caddy and it’s working fine now.

Thanks for your help!

1 Like

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