Let’s Encrypt 証明書取得時に「Problem binding to port 80: Could not bind to IPv4 or IPv6.」発生時の対処法

Let’s Encrypt 証明書取得時に「Problem binding to port 80: Could not bind to IPv4 or IPv6.」発生時の対処法

Let’s Encryptで証明書を取得するため「certbot(certbot-auto) 」実行時に発生。対処法を記述してます。

環境

  • OS CentOS Linux release 7.7.1908 (Core)

事象

certbot-auto実行時に発生。

./certbot-auto certonly --standalone -d example.com -m example@example.com --agree-tos -n

実行結果

Creating virtual environment...
Installing Python packages...
Installation succeeded.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Cleaning up challenges
Problem binding to port 80: Could not bind to IPv4 or IPv6.

原因

証明書を取得するときに、80番ポートを利用するので、 apache等のWEBサーバーが起動していて、すでに80番ポートが利用されてしまって、利用できなくなってしまうことが原因

対処法

一旦WEBサーバーを停止させる
自分の場合はcaddyを利用していたので下記となります。

systemctl stop caddy

apacheの場合は下記で停止できます。

systemctl stop httpd