Error Running Client: Expected </VirtualHost> but saw </VirtualHost></IfModule>


I can’t replicate it on my system, and not one I’ve come across ( the same for others I’d guess since you haven’t had lots of replies).

It might be worth flagging up as a bug on github - alternatively, try one of the many other clients


Thanks for the help, I will try completely re-making the server box from scratch later and see if that fixes my issues.


@groovyben008 Just seeing a common link of 2 others with the same issue … they had owncloud - are you using owncloud or anything that might be affecting the apache config in the same way ?


Nope, using a new digitalocean droplet with a self-installed LAMP stack.


This is happening to me as well, on a Debian VPS. I had it enabled for three domains with no issues, tried to add a fourth and began getting this.

Clearly, the script is at least temporarily writing out the le-ssl.conf. I’ve been trying for an hour to figure out if there is a way to get the script to output said file for me to review, but have had no luck at all.


Still haven’t fixed this issue, so no ideas…


Would you mind sharing your full apache config? Specifically, those files might be of interest:

  • /etc/apache2/apache2.conf
  • /etc/apache2/conf.d/*
  • /etc/apache2/sites-enabled/*
  • /etc/apache2/sites-available/*
  • Any other conf file anywhere (conf-enabled, mods-enabled, …) you might have modified or included from inside other conf files.


I have pretty much the same problem. Ubuntu 14.04, apache2. Cleaninstall (well, phpmyadmin is installed) and just one virtual host conf file

<VirtualHost *:80 >
	DocumentRoot "/var/www/projects/mydomain/public"
	ErrorLog "/var/www/projects/mydomain/logs"

Removing the ServerAlias doesn’t change anything. Not sure what to do here? :frowning:

apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Syntax error on line 12 of /etc/apache2/sites-enabled/mydomain-le-ssl.conf: Expected </VirtualHost> but saw </VirtualHost></IfModule>

I uploaded my apache.conf to pastebin but I don’t think there’s anything wrong with it?! I checked all the files that get included in lines 216 & 219 and everything looks good to me. I tried to output the mydomain-le-ssl.conf file but I had no luck with that so far.

All the files in /sites-enabled/ are symlinks to their respective files in /sites-available/, shouldn’t it be the same for the le-ssl.conf?


I had this problem as well. I solved it by pressing ENTER after and running the installation again.


I fixed this by putting a newline at the end of the conf file.


As said by @Konrad90, adding a newline to the end of each file fixed this issue for me.


newline fixed the issue. Thank You!


Fixed adding the new line as suggested. Here’s a one-liner:

for f in /etc/apache2/sites-available/*; do sed -i '$a\' "$f"; done



Just add an empty line at the end of your .conf file into the directory sites-available/


Thank You!
one newline at bottom fix this!


Thanks from me too, newline sorted it, now on to the next issue in my slightly sketchy apache setup, all sites appear to redirect to one default :stuck_out_tongue:


did it for me, too.
many thanks!


Just created an account here to confirm that the newline solved this for me as well. I would have never found this myself, so thanks a lot!

Since a stand-alone apache config test does not report such a syntax error, does that mean that the letsencrypt certbot is overly sensitive to it?


Yes, it is too sensitive.


I created a new file /etc/apache2/sites-available/my.domain.conf and then I was facing similar problem with configtest as cray or groovyben008 did: not matched and tags, although visually they looked OK.
It was caused by three garbage bytes - UTF-8 BOM - which my editor had put in front of . Theese bytes are invisible in most text viewers and Apache conf parser isn’t smart enough to ignore them.
So if configtest reports inexplicable error, look at the file with hexa viewer xxd.