Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

nginx will not start because the SSL certificate file is missing

Errornginx: [emerg] cannot load certificate "/etc/nginx/ssl/example.com.crt": ... No such file or directory

Short answer

nginx opens every certificate and key file named in the config while it starts, and one of them is not there. The log line gives the full path. Check that path with ls: it is either misspelled, not issued yet (a Let's Encrypt path before certbot ran), or a copy that was moved out of certbot's live folder.

  • Applies to nginx 1.26 and 1.28, Certbot 3.x, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run the config test. It tries to open the files named in the config, so it prints the failing path. Then list that path.

    sudo nginx -t
    sudo ls -l /etc/nginx/ssl/ /etc/letsencrypt/live/
  2. 2Match what you see, then jump to its fix

    1. 1cannot load certificate "<path>" and ls shows no such file at that path, or a different name or extensionThe path in ssl_certificate or ssl_certificate_key is wrongFix
    2. 2The missing path starts with /etc/letsencrypt/live/<domain>/The Let's Encrypt certificate has not been issued yetFix
    3. 3The config points to a private copy (for example /etc/nginx/ssl/) that no longer matches Certbot's filesFiles were copied out of the live folder and later removed or renamedFix

What does the error look like?

  • nginx: [emerg] cannot load certificate "/etc/nginx/ssl/example.com.crt": ... No such file or directory
  • nginx: [emerg] cannot load certificate key "/etc/nginx/ssl/example.com.key": ... No such file or directory

Cause 1 of 3

The path in ssl_certificate or ssl_certificate_key is wrong

1Check

Compare each path in the config with the real file names, including .crt versus .pem and the domain spelling.

grep -rn "ssl_certificate" /etc/nginx/
sudo ls -l /etc/nginx/ssl/

2Fix

Correct the paths. Use full absolute paths, so the result does not depend on where nginx runs from. Both files must exist, and the key must be readable by the nginx master process.

ssl_certificate     /etc/nginx/ssl/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com.key;

3Verify

The test passes and the file is opened.

sudo nginx -t

Confirmed by nginx.org

Did this fix it?

Cause 2 of 3

The Let's Encrypt certificate has not been issued yet

1Check

A config that already names the Certbot files cannot start before Certbot has created them. Ask Certbot what it holds.

sudo certbot certificates

2Fix

Comment out the 443 block (or use only listen 80), start nginx, then get the certificate. certbot certonly obtains it without installing, and the nginx plugin obtains and installs it. Re-enable the 443 block afterwards.

sudo certbot certonly --nginx -d example.com -d www.example.com

3Verify

The live folder now holds fullchain.pem and privkey.pem.

sudo ls -l /etc/letsencrypt/live/example.com/

Confirmed by eff-certbot.readthedocs.io

Did this fix it?

Cause 3 of 3

Files were copied out of the live folder and later removed or renamed

1Check

Certbot keeps the current files under /etc/letsencrypt/live/<name>/ and updates them on renewal. A copy elsewhere does not follow renewal, and breaks if the copy is deleted.

sudo certbot certificates
grep -rn "ssl_certificate" /etc/nginx/

2Fix

Point nginx straight at the live files, as the Certbot docs advise, instead of at copies. fullchain.pem is the certificate plus intermediates.

ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

3Verify

Test and reload.

sudo nginx -t && sudo systemctl reload nginx

Confirmed by eff-certbot.readthedocs.io

Did this fix it?

How do I stop it coming back?

  • Run nginx -t before every reload or restart; it opens each certificate file for you.
  • Reference Certbot's live paths directly and never keep manual copies.
  • Add the 443 server block only after the certificate exists.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.