nginx will not start because the SSL certificate file is missing
nginx: [emerg] cannot load certificate "/etc/nginx/ssl/example.com.crt": ... No such file or directoryShort 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.
Fix it fast
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/2Match what you see, then jump to its fix
- 1
cannot 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
The missing path starts with /etc/letsencrypt/live/<domain>/The Let's Encrypt certificate has not been issued yetFix - 3
The 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
- 1
What does the error look like?
nginx: [emerg] cannot load certificate "/etc/nginx/ssl/example.com.crt": ... No such file or directorynginx: [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 -tConfirmed by nginx.org
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 certificates2Fix
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.com3Verify
The live folder now holds fullchain.pem and privkey.pem.
sudo ls -l /etc/letsencrypt/live/example.com/Confirmed by eff-certbot.readthedocs.io
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 nginxConfirmed by eff-certbot.readthedocs.io
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
Servers
nginx refuses to start: private key does not match the certificate
SSL: error:05800074:x509 certificate routines::key values mismatch
nginx pairs the private key with the first certificate in the ssl_certificate file.
2 causes, each with a fixServers
A Let's Encrypt certificate did not renew with Certbot
Type: connection ... Timeout during connect (likely firewall problem)
Run sudo certbot renew --dry-run and read the Type and Detail lines.
6 causes, each with a fixServers
curl cannot connect to port 80 or 443 on a server running nginx
CURLE_COULDNT_CONNECT (7): Failed to connect() to host or proxy
Exit code 7 means the TCP connection itself failed, before any HTTP happened.
3 causes, each with a fixServers
Django returns a 500 behind Gunicorn and the traceback is nowhere
The traceback shows locally with runserver but not under Gunicorn
With DEBUG set to False, Django's default logging does not print errors to the console.
2 causes, each with a fixServers
Your website on a Google Compute Engine VM times out on port 80
The site works with curl on the VM but not from outside
A timeout, as opposed to a refusal, usually means a firewall dropped the packets.
3 causes, each with a fixServers
Gunicorn rejects a request with "Error parsing headers: limit request headers fields size"
Error parsing headers: 'limit request headers fields'
Gunicorn caps the size of one header field at 8190 bytes and the number of headers at 100 by default.
2 causes, each with a fix