About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
The line no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/conf.d/catchall.conf:1 means that for one address and port with ssl on the listen line, the default server has no certificate. nginx refuses the whole configuration. The file and line at the end of the message name the server block that nginx treats as the default for that port, which is often not the block you were editing. Give that block a certificate, or give the whole http level one, then test and reload.
What the error means
In the nginx 1.30.8 source, after the configuration is read, nginx goes through every address and port that has the ssl parameter on a listen directive. It looks at the default server of that pair. If that server has no certificate and ssl_reject_handshake is not on, it logs the message at the emerg level and stops with an error. The text is no "ssl_certificate" is defined for the "listen ... %s" directive in %s:%ui, where the first %s is ssl (or quic) and the rest is the file name and line of the server block.
The nginx documentation on listen explains which server is the default: the default_server parameter makes a server "the default server for the specified address:port pair", and if none has it, "the first server with the address:port pair will be the default server". The source test above looks at the default server of each pair, so that is the block that needs a certificate of its own, or ssl_reject_handshake on;.
The same source has a second form of the test. If the default server has ssl_reject_handshake on, nginx checks the other server blocks on that port and logs the same message for the first one that has no certificate and does not reject handshakes.
On a reload, the Beginner's Guide says that when the new configuration cannot be applied the master process "rolls back the changes and continues to work with the old configuration". Our own reading: on a start there is no old configuration, so nginx does not start.
A different message, no "ssl_certificate_key" is defined for certificate "%V", appears in the same source when a certificate line has no matching key line. For a certificate and key that do not belong together, see nginx will not start after a certificate change: key values mismatch between certificate and private key.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
A catch-all or default block listens with ssl but has no certificate lines |
The file and line in the message point at that block | The block at that file and line has listen 443 ssl and no ssl_certificate |
| The certificate lines are in the block you edited, which is not the default for the port | Your block looks complete, but the error remains | Another block is first for that address and port, or has default_server |
ssl was added to a listen line by mistake |
A plain HTTP site is now treated as an HTTPS port | The line is listen 80 ssl or similar |
| The certificate lines were commented out or deleted during a renewal or edit | The block used to work | Lines start with #, or the saved copy has them |
The certificate is meant to be shared and was set at http level, but the line was removed there |
Several blocks fail together | No ssl_certificate in the http block of the dump |
Prove the cause before changing anything
All of these steps only read.
1. Run the configuration test and write down the line. The nginx documentation describes -t as a check of the syntax that "then tries to open files referred in the configuration".
nginx -t
Write down the file name and line number at the end of the message.
2. Read the block at that file and line. Open the file in an editor or pager at that line. Look for listen, server_name, default_server, ssl_certificate, ssl_certificate_key and ssl_reject_handshake.
3. List every block on that port. The nginx documentation describes -T as "same as -t, but additionally dump configuration files to standard output".
nginx -T
Search the output for every listen line that has the same port. The first block read for an address and port is its default server unless another has default_server. Our own reading: a block with listen 443 ssl and no default_server that is read before your site is the one the message names.
4. Check where certificates are set. Search the dump for ssl_certificate. The directive is allowed at http and server level, so a certificate at http level covers every block that does not set its own. The HTTPS documentation says it is better to place a certificate with several names and its key "at the http level of configuration to inherit their single memory copy in all servers".
Fix
Choose the route that matches what steps 2 to 4 showed. Every route edits a configuration file, so each starts with a saved copy.
First save the current state, using the file name from the message. The GNU manual says "cp copies files (or, optionally, directories)."
cp -p /etc/nginx/conf.d/catchall.conf /root/catchall.conf.2026-12-04
Our own advice: keep the saved copy outside any directory that an include line reads, so nginx does not read it as a second site.
Risk: the next edit changes which certificate nginx offers on a port. A wrong file name makes the test fail, and a certificate for the wrong name makes browsers show a name warning after the reload.
Edit the default server block named in the message. Use only the one route that applies.
- The block should serve HTTPS: add the certificate and key lines the HTTPS documentation shows, with your own file names.
- The block is only a catch-all that should refuse unknown names: add
ssl_reject_handshake on;, which appeared in nginx 1.19.4 and rejects SSL handshakes in that block. The documentation example puts it in adefault_serverblock. - The
sslon thelistenline was a mistake: remove the wordsslfrom that line.
Risk: removing the word ssl from a listen line is a different kind of change from adding certificate lines. That port stops answering HTTPS: a visitor who connects with HTTPS to it will no longer get a TLS handshake from that block. Use this route only for a port that was never meant to serve HTTPS.
For a certificate, the lines have this form:
ssl_certificate /etc/nginx/certs/example.com.crt;
ssl_certificate_key /etc/nginx/certs/example.com.key;
For a catch-all that refuses unknown names, the documentation form is:
listen 443 ssl default_server;
ssl_reject_handshake on;
Risk: copying the saved file over the edited one discards the edit. The error returns.
Only if you need to back out before the reload: copy the saved file over the edited one.
cp -p /root/catchall.conf.2026-12-04 /etc/nginx/conf.d/catchall.conf
Run the test on its own.
nginx -t
If the same message names another file and line, that file is a new change. Save it first under its own name, using its file name from the message.
cp -p /etc/nginx/conf.d/second.conf /root/second.conf.2026-12-04
Risk: the next edit changes which certificate nginx offers on a port, in a second file.
Repeat the edit for that block, then run the test on its own again. When the test passes, reload.
Only if you need to back out the second file before the reload: copy its saved copy over it. Run this only if you edited the second file.
Risk: copying the saved file over the edited one discards the edit in the second file. The error returns for that block.
cp -p /root/second.conf.2026-12-04 /etc/nginx/conf.d/second.conf
The saved copies are the configuration being replaced. Keep them until the reload has been checked.
Disruptive step: the next command loads the new configuration and starts new worker processes. A failed reload keeps the old configuration, according to the Beginner's Guide, but a successful one changes the certificate offered on that port at once.
nginx -s reload
Risk: the back-out below restores the saved file over the live one and then loads it with a second reload. The change you made is lost, and the certificate offered on that port changes again.
Only if you need to back out after the reload, copy the saved file back. Run only the one that applies, and run both if you edited two files.
For the file named in the message:
cp -p /root/catchall.conf.2026-12-04 /etc/nginx/conf.d/catchall.conf
For the second file, only if you edited it:
cp -p /root/second.conf.2026-12-04 /etc/nginx/conf.d/second.conf
Then run the test on its own.
nginx -t
Then load the restored file with a second reload.
nginx -s reload
Example (illustrative): on web01, nginx -t fails with no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/conf.d/catchall.conf:1. The administrator had added the certificate lines to /etc/nginx/conf.d/example.conf, which listens on 443 ssl for www.example.com. The file catchall.conf is read first, has listen 443 ssl; and no certificate, so it is the default server for the port. The administrator saves catchall.conf, adds ssl_reject_handshake on; and default_server to its listen line, runs nginx -t with no errors, and reloads. Requests for www.example.com still get its certificate.
Confirm the fix
nginx -tprints nono "ssl_certificate" is definedline and does not fail.- After the reload,
curl -I https://www.example.com/returns headers without a certificate error. - Compare the certificate name the server offers with the name in the browser's address bar for each site on the port.
- A name that is not on the server should be refused if you used
ssl_reject_handshake on;.
What to watch afterwards
- Run
nginx -tafter every edit to a site file. - When you add an HTTPS site, check which block is the default for the port.
- Our own advice: set the default server of each
sslport on purpose, with either a certificate orssl_reject_handshake on;. - If the wrong certificate appears for a name, see Browser shows the wrong certificate for a site: SNI and the default virtual host.
Read next
Related articles you may want next.
- Troubleshootingnginx will not start after a certificate change: key values mismatch between certificate and private keynginx SSL_CTX_use_PrivateKey_file failed, key values mismatch: prove which file is wrong with openssl, fix the pair or chain order, and test with nginx -t.Read article
- Hostingnginx warning: conflicting server name "example.com" on 0.0.0.0:80, ignorednginx: conflicting server name on 0.0.0.0:80, ignored. Two server blocks claim one name. Find both with nginx -T, keep one, test and reload safely.Read article
- HostingApache AH00526: SSLCertificateFile "does not exist or is empty": Apache refuses to startApache AH00526: SSLCertificateFile file does not exist or is empty. Read the line number, check the path against certbot, fix it and test before starting.Read article
Risks and limits
- These commands have not been run or lab-tested.
- The message wording and the emerg level come from the nginx 1.30.8 source. Other versions may log other text.
- The file and line in the message are those of a server block. An included file can hide which of several blocks is meant.
- Editing certificate lines on a production server changes what visitors see. Our own advice: make the change outside busy hours.
- A duplicate server name is a different fault: see nginx warning: conflicting server name "example.com" on 0.0.0.0:80, ignored.
Sources
- nginx 1.30.8 source: src/http/modules/ngx_http_ssl_module.c — nginx project, tag release-1.30.8, no date shown, accessed 4 December 2026
- Configuring HTTPS servers — nginx documentation, no date shown, accessed 4 December 2026
- Module ngx_http_ssl_module — nginx documentation, no date shown, accessed 4 December 2026
- Module ngx_http_core_module — nginx documentation, no date shown, accessed 4 December 2026
- Command-line parameters — nginx documentation, no date shown, accessed 4 December 2026
- Beginner’s Guide — nginx documentation, no date shown, accessed 4 December 2026
- nginx: download — nginx.org, no date shown, accessed 4 December 2026
- curl man page — curl project, no date shown, accessed 4 December 2026
- cp invocation — GNU Coreutils 9.12 manual, no date shown, accessed 4 December 2026
- cp(1) — Linux manual page — Linux man-pages project, no date shown, accessed 4 December 2026
This article was originally published on .