Can't renew certificate: We were unable to find a vhost with a ServerName or Address

Hi, I’m trying to test the renewal of my certificate using
letsencrypt renew --agree-tos --dry-run

but getting the following error:

2016-02-28 11:50:35,980:WARNING:letsencrypt.cli:Attempting to renew cert from /etc/letsencrypt/renewal/btcontract.com.conf produced an unexpected error: Failed to run Apache plugin non-interactively
Missing command line flag or config entry for this setting:
We were unable to find a vhost with a ServerName or Address of btcontract.com.
Which virtual host would you like to choose?
Choices: [‘000-default-le-ssl.conf | | HTTPS | Enabled’, ‘000-default.conf | | | Enabled’, 'le-redirect.conf | | | ', ‘default-ssl.conf | | HTTPS | Enabled’]
(The best solution is to add ServerName or ServerAlias entries to the VirtualHost directives of your apache configuration files.). Skipping.

ls /etc/apache2/sites-available/ gives

000-default-le-ssl.conf 000-default.conf default-ssl.conf le-redirect.conf

As far as I understand letsencrypt wants me to put some parameters (namely, ServerName or ServerAlias) in one (or more?) of these files but I’m not that good at managing Apache so I’d like to ask what exactly do I have to do here? Thanks!

In these config files you need to make sure there is a line that says "ServerName btcontract.com" but only if all the defaults are for one website. usually it is default to example.com - It tells your apache server what the site identifies as and where the root of the website is (DocumentRoot /var/www etc...)

Thanks, adding

    ServerName btcontract.com
    ServerAlias www.btcontract.com

to 000-default-le-ssl.conf did the trick.

2 Likes

This helped me with similar setup on DigitalOcean. Thanks