MeWrite Docs

Certbot: Challenge failed

CertbotでSSL証明書の取得に失敗した場合のエラー

概要

Challenge failed は、CertbotでLet’s Encryptの証明書を取得する際に、ドメイン所有者の検証に失敗した場合に発生するエラーです。

エラーメッセージ

Challenge failed for domain example.com
http-01 challenge for example.com
Cleaning up challenges
IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: example.com
   Type:   unauthorized
   Detail: Invalid response from http://example.com/.well-known/acme-challenge/xxx
Timeout during connect (likely firewall problem)
DNS problem: NXDOMAIN looking up A for example.com

原因と解決策

1. ポート80がブロックされている

1
2
3
4
5
6
# ファイアウォール確認(Ubuntu)
sudo ufw status

# ポート80を開放
sudo ufw allow 80
sudo ufw allow 443

2. Webサーバーが起動していない

1
2
3
4
5
# Nginxの状態確認
sudo systemctl status nginx

# 起動
sudo systemctl start nginx

3. ドメインのDNS設定が間違っている

1
2
3
4
5
6
# DNSの確認
dig example.com A
dig example.com AAAA

# サーバーのIPアドレスと一致しているか確認
curl -I http://example.com

4. .well-known ディレクトリへのアクセスがブロック

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Nginxの設定
server {
    listen 80;
    server_name example.com;

    # ACMEチャレンジ用
    location /.well-known/acme-challenge/ {
        root /var/www/html;
    }

    # その他のリクエストはHTTPSにリダイレクト
    location / {
        return 301 https://$host$request_uri;
    }
}

5. Webroot の設定

1
2
3
4
5
6
7
# webrootモードで実行
sudo certbot certonly --webroot -w /var/www/html -d example.com

# または standalone モード(サーバーを一時停止)
sudo systemctl stop nginx
sudo certbot certonly --standalone -d example.com
sudo systemctl start nginx

6. DNS認証を使用(ワイルドカード証明書)

1
2
3
4
5
# DNSチャレンジを使用
sudo certbot certonly --manual --preferred-challenges dns -d "*.example.com"

# CloudflareなどのAPIを使用
sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials ~/.secrets/cloudflare.ini -d example.com

7. レート制限に達した場合

Error: urn:ietf:params:acme:error:rateLimited
1
2
3
4
5
# ステージング環境でテスト
sudo certbot certonly --staging -d example.com

# 成功したら本番環境で実行
sudo certbot certonly -d example.com

デバッグ方法

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 詳細ログ
sudo certbot certonly --debug -d example.com

# ドライラン
sudo certbot certonly --dry-run -d example.com

# 証明書の状態確認
sudo certbot certificates

# ログ確認
sudo tail -f /var/log/letsencrypt/letsencrypt.log

自動更新の設定

1
2
3
4
5
6
# 自動更新テスト
sudo certbot renew --dry-run

# cronまたはsystemd timerで自動更新
# /etc/cron.d/certbot
0 0,12 * * * root certbot renew --quiet

関連エラー

関連エラー

Security の他のエラー

最終更新: 2025-12-17