Error Message from Certbot
This post is base on Amazon Linux 2023.
When requesting a certificate for example.com, you might see an error similar to this:
Requesting a certificate for example.com
Unable to find a virtual host listening on port 80 which is currently needed for Certbot to prove to the CA that you control your domain. Please add a virtual host for port 80.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile/var/log/letsencrypt/letsencrypt.log
or re-run Certbot with-v
for more details.
Steps to Create an Apache Virtual Host for Port 80
Step 1: Open or Create the Virtual Host Configuration File
Navigate to the directory where Apache stores its configuration files. On Amazon Linux, this is usually located in /etc/httpd/conf.d/
. Create a new configuration file for your domain:
sudo nano /etc/httpd/conf.d/example.com.conf
Step 2: Add the VirtualHost Configuration
In the file, add the following configuration for your domain:
<VirtualHost *:80> ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/html <Directory /var/www/html> AllowOverride All Require all granted </Directory> </VirtualHost>
Replace /var/www/html
with the correct document root for your site if it’s different.
Step 3: Save and Exit the Editor
In nano, press Ctrl + X
, then Y
to confirm, and Enter
to save.
Step 4: Restart Apache
Apply the new configuration by restarting Apache:
sudo systemctl restart httpd
Step 5: Verify Apache is Listening on Port 80
Check that Apache is now configured to listen on port 80:
sudo netstat -tuln | grep 80
Once this is complete, you can retry Certbot to obtain your SSL certificate. Apache should now be configured properly to listen on port 80 for example.com.