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

**Code:** `Could not automatically find a matching server block` · **Category:** SSL / TLS · **Seen on:** SSL, Nginx, Linux

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ssl/certbot-nginx-no-matching-server-block)
