Cannot generate cert for 2nd domain/vhost on apache2

My domain is: /

I ran this command:

sudo certbot --apache

It produced this output:

zack@zs-com-01:/var/www/zacksjodencom$ sudo certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log

Which names would you like to activate HTTPS for?
We recommend selecting either all domains, or all domains in a VirtualHost/server block.


Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1 2
Requesting a certificate for and

Certbot failed to authenticate some domains (authenticator: apache). The Certificate Authority reported these problems:
Type: unauthorized
Detail: Invalid response from 404

Type: unauthorized
Detail: Invalid response from 404

Hint: The Certificate Authority failed to verify the temporary Apache configuration changes made by Certbot. Ensure that the listed domains point to this Apache server and that it is accessible from the internet.

Some challenges have failed.
Ask for help or search for solutions at See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

My web server is (include version):

Server version: Apache/2.4.52 (Ubuntu)
Server built: 2023-10-26T13:44:44

The operating system my web server runs on is (include version):

Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy

My hosting provider, if applicable, is:


I can login to a root shell on my machine (yes or no, or I don't know):


I'm using a control panel to manage my site (no, or provide the name and version of the control panel):


The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot):

certbot --version
certbot 2.8.0

I was able to initially generate a certificate for and I then added a new virtualhost, and am unable to generate a cert for that one,

I made no apache2 config changes. I setup the vhost file exactly the same way as the first one. I can serve the index.html file from with no issue. is trying to use the cert for I don't know if that is related to the issue, normal, or will be resolved when I get a cert successfully generated for this second website.

The letsdebug site indicates no issues:

Test result for using http-01

All OK!


No issues were found with If you are having problems with creating an SSL certificate, please visit the Let's Encrypt Community forums and post a question there.

1 Like

Welcome to the community @sjodenzack

Let's start by checking your Apache VirtualHosts. Please show output of this

sudo apache2ctl -t -D DUMP_VHOSTS

That would seem to be (at least part of) "the problem".


@MikeMcQ, here is the output:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration: (/etc/apache2/sites-enabled/137_184_44_71.conf:1)
*:443  (/etc/apache2/sites-enabled/zacksjodencom-le-ssl.conf:2)
*:80 is a NameVirtualHost
default server (/etc/apache2/sites-enabled/nullminimalcom.conf:1)
port 80 namevhost (/etc/apache2/sites-enabled/nullminimalcom.conf:1)
port 80 namevhost (/etc/apache2/sites-enabled/zacksjodencom.conf:1)

@rg305 I figured as much, but I can't figure out how/why.

Edit: Surely adding new virtualhost(s) and wanting a cert for them would be "normal" after setting up an initial site. I can't imagine it should be that complicated to add a new site and get another cert for that domain as well.

1 Like

Let's have a look at these files.



I created this one as I wanted to control what people saw when/if someone put in the IP directly. Also, both this and the domains/vhosts were added after I successfully got a cert for the vhost:
zack@zs-com-01:~$ cat /etc/apache2/sites-enabled/137_184_44_71.conf

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/137_184_44_71
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

This was auto-generated(I didn't create it) after running cert-bot successfully for my first domain/vhost.
zack@zs-com-01:~$ cat /etc/apache2/sites-enabled/zacksjodencom-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/zacksjodencom
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/

Let me know if you need to see anything else. Appreciate the help.

Edit: Fixed formatting.

(It's better to use the </> button or three backticks (```) above and below the code instead of using quotes.)


@Osiris Thank you. I will do that going forward if that makes things easier/more readable.

Yeah, that's now how Apache works when you specify an IP address in the VirtualHost statement. Doing that creates an IP based VirtualHost which takes priority for any request for that IP and port. This is why proper HTTP requests are not going to the correct VirtualHost (your name-based ones)

It is fine to setup a default VirtualHost but just use a "fake" ServerName and have a VirtualHost like your others (with *:80). Place it as your first VirtualHost in the series. This will then catch any non-SNI request and SNI requests with the wrong domain names.


@MikeMcQ Should I then remove that virtual host config, reload apache, and try to get the cert again using cert-bot?

You can. Or, another option to make that a proper default vhost is
That first example catches any port but usually people set it to an explicit port like

<VirtualHost _default_:80>

@MikeMcQ Disabling that site's config and reloading apache fixed the issue. I feel dumb.

Thank you @MikeMcQ and @rg305 for your help this morning, on a holiday no less. Very much appreciated.


No worries. Seems like a case of a little knowledge being a dangerous thing :slight_smile:



Yeah. I've been out of the web dev game for a few years. And even then it was just hobby LAMP based sites. Just started up a couple weeks ago trying to get back into it and this is my first time using LetsEncrypt.

Thank you again.


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