# Nginx: \[emerg\] no "ssl\_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/conf.d/site.com.conf:7

**URL:** https://community.letsencrypt.org/t/nginx-emerg-no-ssl-certificate-is-defined-for-the-listen-ssl-directive-in-etc-nginx-conf-d-site-com-conf-7/204356
**Category:** Help
**Created:** [August 31, 2023, 5:33am UTC](https://community.letsencrypt.org/t/nginx-emerg-no-ssl-certificate-is-defined-for-the-listen-ssl-directive-in-etc-nginx-conf-d-site-com-conf-7/204356 "2023-08-31T05:33:13Z")
**Posts on this page:** 6
**Page:** 2

<div class="post-metadata">

### Author: ![elcarim](https://avatars.discourse-cdn.com/v4/letter/e/ad7895/32.png) [@elcarim](https://community.letsencrypt.org/u/elcarim)
#### Post date: [August 31, 2023, 8:28am UTC](https://community.letsencrypt.org/t/nginx-emerg-no-ssl-certificate-is-defined-for-the-listen-ssl-directive-in-etc-nginx-conf-d-site-com-conf-7/204356/21 "2023-08-31T08:28:48Z")

</div>

> [@Osiris](#):
>
> It would be weird for _all_ websites to have that specific certificate set up, as your certificate is only for `recipe.org.ua` and `www.recipe.org.ua`. Not any other website.

will see pregnancy.org.ua

> [@Osiris](#):
>
> Hm, that shouldn't have happened. If you requested a cert for just the `recipe.org.ua` site, Certbot _should_ leave the other websites alone, unless those were somehow misconfigured in their `server_name` directive?

I don't know how to answer this question! now the sites are working, that's good, but still I would like to understand how to do it right.  
I don't want /recipe.org.ua/privkey.pem etc. to be used everywhere.

and perhaps the old directives were shorter and better.

maybe i should uninstall and reinstall again certbot.

Despite all the difficulties and imperfections, I am immensely grateful to you, as you helped me make my websites work. Thank you from me in Ukraine!

---

<div class="post-metadata">

### Author: ![Osiris](https://avatars.discourse-cdn.com/v4/letter/o/839c29/32.png) [@Osiris](https://community.letsencrypt.org/u/Osiris)
#### Post date: [August 31, 2023, 8:40am UTC](https://community.letsencrypt.org/t/nginx-emerg-no-ssl-certificate-is-defined-for-the-listen-ssl-directive-in-etc-nginx-conf-d-site-com-conf-7/204356/22 "2023-08-31T08:40:21Z")

</div>

> [@elcarim](#):
>
> will see pregnancy.org.ua

It looks like that site has a certificate for (probably) _all_ hostnames known to your nginx. That's not a real problem. The only thing is all hostnames are visible in that single certificate.

> [@elcarim](#):
>
> I don't know how to answer this question! now the sites are working, that's good, but still I would like to understand how to do it right.  
> I don't want /recipe.org.ua/privkey.pem etc. to be used everywhere.

It looks like you didn't select any specific hostname when Certbot asked for it, so it used _all_ hostnames known to nginx and requested a certificate for _all_ those hostnames.

> [@elcarim](#):
>
> maybe i should uninstall and reinstall again certbot.

That isn't necessary. While it might be some work, you can reinstall existing certificates (if still known to Certbot) by selecting _specific_ hostnames. This can be done using the interactive menu in Certbot, but you can also select them on the command line, e.g.:

```
sudo certbot --nginx -d pregnancy.org.ua -d www.pregnancy.org.ua

```

That way Certbot will only use those specific hostnames and thus also only the `server` blocks in nginx specific to those hostnames. If Certbot already knows about an existing certificate, it would ask you to reinstall that cert, which is fine.

That said, it seems you now have _overlapping_ certificates: multiple "single site" certificates and also a single "multi site" certificate. So you might need to specify a specific certificate name using `--cert-name name-of-the-cert-here`. You can find all the certificates and their name and included hostnames by running `sudo certbot certificates`.

---

<div class="post-metadata">

### Author: ![elcarim](https://avatars.discourse-cdn.com/v4/letter/e/ad7895/32.png) [@elcarim](https://community.letsencrypt.org/u/elcarim)
#### Post date: [August 31, 2023, 8:57am UTC](https://community.letsencrypt.org/t/nginx-emerg-no-ssl-certificate-is-defined-for-the-listen-ssl-directive-in-etc-nginx-conf-d-site-com-conf-7/204356/23 "2023-08-31T08:57:57Z")

</div>

```plaintext
#!/bin/bash
domains=("site1" "site2" "siteN" )
for domain in "${domains[@]}"
do
    certbot --nginx -d "$domain" -d www."$domain"
done

```

```plaintext
chmod +x update_certificates.sh

```

```plaintext
sed -i 's/\r//' /etc/nginx/conf.d/update_certificates.sh

```

```plaintext
/etc/nginx/conf.d/update_certificates.sh

```

---

<div class="post-metadata">

### Author: ![Osiris](https://avatars.discourse-cdn.com/v4/letter/o/839c29/32.png) [@Osiris](https://community.letsencrypt.org/u/Osiris)
#### Post date: [August 31, 2023, 9:05am UTC](https://community.letsencrypt.org/t/nginx-emerg-no-ssl-certificate-is-defined-for-the-listen-ssl-directive-in-etc-nginx-conf-d-site-com-conf-7/204356/24 "2023-08-31T09:05:39Z")

</div>

I'm not an Bash expert, but that might or might not work due to the lack of `--cert-name` as mentioned earlier. Maybe you're lucky and it just works. Maybe you're lucky and all the single site certificates are actually called "$domain"? Or if you're unlucky it's a mix of $domain and www.$domain 😬

---

<div class="post-metadata">

### Author: ![rg305](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/rg305/32/91314_2.png) [@rg305](https://community.letsencrypt.org/u/rg305)
#### Post date: [August 31, 2023, 12:49pm UTC](https://community.letsencrypt.org/t/nginx-emerg-no-ssl-certificate-is-defined-for-the-listen-ssl-directive-in-etc-nginx-conf-d-site-com-conf-7/204356/25 "2023-08-31T12:49:44Z")

</div>

> [@elcarim](#):
>
> `update_certificates.sh`

Not sure what the "update" in that command means...  
But once the certificates have been created, you only need to renew them - with:  
`certbot renew`

And why would you save it that `nginx` folder?:

> [@elcarim](#):
>
> `/etc/nginx/conf.d/`

Please show:  
`nginx -T | grep -i include`

---

<div class="post-metadata">

### Author: ![system](https://global.discourse-cdn.com/letsencrypt/original/3X/c/a/ca6c06ea1ea201324bba7048c6841ce60236468d.png) [@system](https://community.letsencrypt.org/u/system)
#### Post date: [September 30, 2023, 12:50pm UTC](https://community.letsencrypt.org/t/nginx-emerg-no-ssl-certificate-is-defined-for-the-listen-ssl-directive-in-etc-nginx-conf-d-site-com-conf-7/204356/26 "2023-09-30T12:50:36Z")

</div>

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

[Previous page](https://community.letsencrypt.org/t/nginx-emerg-no-ssl-certificate-is-defined-for-the-listen-ssl-directive-in-etc-nginx-conf-d-site-com-conf-7/204356.md?page=1)
