Could not automatically find a matching server block SSL / TLS Origin: Network OSI layer 7 · Application Last updated 4 Nov 2026

Certbot: Could not automatically find a matching server block for example.com. Set the `server_name` directive to use the Nginx installer

Certbot's Nginx plugin could not find a server block whose server_name matches the domain you requested.

Exact message you may see Could not automatically find a matching server block forSet the `server_name` directive to use the Nginx installerCould not find a usable 'server' blockcertbot nginx server_name not foundCould not automatically find a matching server block for example.com
Seen on: SSL Nginx Linux

Meaning

The --nginx installer edits configs by server_name. Add the exact domain to a server block (and reload) or switch to certonly --webroot and edit the config yourself. Make sure the config is in an included path (sites-enabled).

Common causes

  • server_name missing or different from -d domain
  • Config not included by nginx.conf
  • Default_server catching everything
  • Typo in domain
  • Config file not symlinked to sites-enabled

⚡ Quick fix

  1. Add server_name example.com www.example.com; and nginx -t && systemctl reload nginx
  2. Or use certbot certonly --webroot -w /var/www/html -d example.com
  3. Check with nginx -T | grep server_name

Detailed fix by platform

Linux

  1. sudo nginx -T | grep -n server_name then sudo certbot --nginx -d example.com -d www.example.com

How to diagnose

  1. server_name — Matches -d?
  2. Include — Config active?
  3. Plugin — nginx or webroot?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

499 Client Closed Request / client prematurely closed connection — Nginx: [info] client prematurely closed connection while reading response header from upstream / access log status 499 (Nginx / Apache)499 Client Closed Req…bind() failed (98: Address already in use) — nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) (Linux)bind() failed (98: Ad…Challenge failed for domain — Let’s Encrypt / Certbot: Challenge failed for domain example.com — Invalid response from http://example.com/.well-known/acme-challenge/x: 404 (SSL / TLS)Challenge failed for …Incorrect TXT record found at _acme-challenge — Certbot: DNS problem: NXDOMAIN looking up TXT for _acme-challenge.example.com / Incorrect TXT record (SSL / TLS)Incorrect TXT record …Invalid response from .well-known/acme-challenge: 404 — Certbot: Detail: Invalid response from http://example.com/.well-known/acme-challenge/abc: 404 (SSL / TLS)Invalid response from…ModSecurity: Access denied with code 403 — Nginx/Apache: ModSecurity: Access denied with code 403 (phase 2). Matched "Operator GE matched 5 at TX:anomaly_score" (Nginx / Apache)ModSecurity: Access d…nginx: [emerg] open() failed (2: No such file or directory) — Nginx: nginx: [emerg] open() "/etc/nginx/snippets/fastcgi-php.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/app:20 (Nginx / Apache)nginx: [emerg] open()…nginx: [emerg] unknown directive — Nginx: nginx: [emerg] unknown directive "x" in /etc/nginx/sites-enabled/x:12 — configuration file test failed (Nginx / Apache)nginx: [emerg] unknow…Could not…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.