Let's Encrypt更新失败:无法绑定IPv4或IPv6。跳过。

76

我收到的完整错误信息是:

Attempting to renew cert from /etc/letsencrypt/renewal/somedomain.com.conf produced an unexpected error: Problem binding to port 443: Could not bind to IPv4 or IPv6.. Skipping.

这是在AWS ubuntu 14.04实例上运行。所有端口都是开放的,出站和443入站也是开放的。


在我的情况下,出现了同样的问题,但我发现我的域名与IP地址没有正确映射。当我使用A记录条目修复IP地址时,一切都很好。 - Tejas Tank
@TejasTank 可能有相同的症状,但很可能是不同的问题。 - eis
12个回答

100

在执行此操作之前,您只需要停止所有正在运行的服务器,如Apache、nginx或OpenShift。

停止 Nginx

sudo systemctl stop nginx

停止 Apache2

sudo systemctl stop apache2

3
这是更新SSL证书的唯一选择吗?在更新时整个服务器都必须关闭吗? - Raz Buchnik
太遗憾了,控制台输出忽略了这个微小的细节。 - Marcus Rohrmoser

81

当你的服务器已经在端口443运行时,你可能会使用(预配置的)--standalone选项来运行脚本。

在更新证书之前,您可以停止服务器,然后在更新完成后重新启动服务器。

man手册上说:

--apache          Use the Apache plugin for authentication & installation
--standalone      Run a standalone webserver for authentication
--nginx           Use the Nginx plugin for authentication & installation
--webroot         Place files in a server's webroot folder for authentication
--manual          Obtain certificates interactively, or using shell script hooks

如果我使用--apache运行续订,我将无法获得任何错误。


7
谢谢...使用 ./certbot-auto renew --apache 命令非常顺利。 - gthuo
请注意,使用 --apache 需要安装 Apache 插件。如果您没有安装该插件,则需要在任何自动更新周围添加停止/启动服务器钩子。 - eis
你必须停止服务器才能这样做吗? - Raz Buchnik
Raz: 不,如果你使用的服务器是Apache,那么调用时需要带上参数--apache;如果使用的是Nginx,则需要带上参数--nginx。 - JKLIR

18

正如其他答案所暗示的那样,您需要为正在运行的Web服务器传递选项,例如:

没有Web服务器参数:

sudo certbot renew
证书即将到期,自动续订... 续订现有证书 执行以下挑战:针对 example.com 的 tls-sni-01 挑战。 清理挑战 尝试从 /etc/letsencrypt/renewal/example.com.conf 更新证书 (example.com),但出现了意外错误: 绑定443端口的问题:无法绑定IPv4或IPv6。 跳过。
接着,再次使用 webserver 参数(成功)。
sudo certbot renew --nginx 
证书即将过期,自动续订中...
续订现有证书
执行以下挑战:tls-sni-01挑战example.com
等待验证...
清除挑战
nginx服务器重载,已部署新证书;fullchain为/etc/letsencrypt/live/example.com/fullchain.pem
恭喜,所有证书续订成功。 已更新以下证书:/etc/letsencrypt/live/example.com/fullchain.pem(成功)

这对我很有效。我不需要停止服务器,只需传递--nginx标志即可。 - Raffi

16

[这是专门针对ubuntu的]

  1. 以root用户身份登录到您的服务器

  2. 使用以下命令停止您的服务器 (如果使用nginx)

    service nginx stop

  3. 然后更新您的证书

    certbot renew

  4. 启动您的服务器

    service nginx start

[提示] 要检查您更新后的证书过期日期,请输入以下命令

ssl-cert-check -c [Path_to_your_certificate]/fullchain.pem
例如
ssl-cert-check -c /etc/letsencrypt/live/[your_domain_name]/fullchain.pem

或者

ssl-cert-check -c /etc/letsencrypt/live/[your_domain_name]/cert.pem

如果您的服务器上尚未安装ssl-cert-check,请使用以下命令进行安装:

apt install ssl-cert-check

注意: 只有在证书未过期时才能进行续签。如果已过期,则必须创建新的证书。


这对于nginx和nodejs服务器非常有用。 - KuLdip PaTel
这对我有用,必须停止nginx然后成功。 - Swapnil Chincholkar

5

对于 nginx

sudo certbot renew --nginx

无法选择适当的插件:请求的nginx插件似乎未安装。 - horvoje

5
对于NodeJS/PM2用户:
我使用PM2来运行我的NodeJS服务,当我尝试更新证书时也收到了“无法绑定IPv4或IPv6端口80”的错误信息。
正如上面提到Apache/Nginx的答案一样,停止我的服务然后尝试更新证书解决了这个问题。
pm2 stop all
sudo certbot renew
pm2 start all

4

首先需要安装NGiNX的Let's Encrypt插件(如果你使用的是 NGiNX):

sudo apt install python-certbot-nginx

然后,您可以安全地运行:

sudo certbot renew --nginx

并且它将会运作。

注意:certbot 应该已经安装好了。


3
这是因为您使用了--standalone选项。该选项的目的是启动一个临时Web服务器,因为您没有正在运行的Web服务器。
下次请使用--webroot方法,这样您就可以使用已经运行的nginx服务器。

2
复制粘贴的解决方案并不是一个好主意。这个错误通常是由于其他进程正在监听端口443而导致的。您可以使用以下命令来查找哪个进程在使用该端口:sudo lsof -i :443然后,您可以杀死该进程或更改Nginx配置以使用其他端口。 - MaXi32
@MaXi32 呵呵,我也是这么想的。 :) - ArchNoob

1
借用@JKLIR的话,只需简单运行即可。
/etc/letsencrypt/letsencrypt-auto renew --apache >> /var/log/letsencrypt/renew.log

更新 SSL 证书


1

在同一实例上运行两个网站(主机)时,我遇到了类似的问题。我停止了Nginx,然后运行了sudo certbot certonly --standalone --preferred-challenges http -d domain.com -d www.domain.com。重启Nginx后,一切都开始正常工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接