Could not automatically find a matching server block even though a server block exists

My domain is:

I ran this command: sudo certbot --nginx -d -d

It produced this output: Could not automatically find a matching server block for Set the server_name directive to use the Nginx installer.

My web server is (include version): nginx/1.20.1

The operating system my web server runs on is (include version): FreeBSD 13.0-Release (1300139)

My hosting provider, if applicable, is: Hetzner Cloud

I can login to a root shell on my machine (yes or no, or I don't know): yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel): No

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): certbot 1.22.0

Additionally, I have made sure that the domain does exist in my nginx config. Here is a partial output of sudo nginx -T:

# configuration file /usr/local/etc/nginx/servers/
server { 
        listen 80;
        listen [::]:80;
        root /usr/local/www/;
        index index.html index.htm;                     

        location / {
		try_files $uri $uri/ /index.html =404;

        location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg)$ {
                expires 365d;

I wasn't able to reproduce this using FreeBSD 13 and Certbot 1.22.0. It worked for me.

Make sure that you added include servers/*.conf; within the http {} block in nginx.conf.


Hi @skyeewers, and welcome to the LE community forum :slight_smile:

Can we have a look at the main nginx.conf file?

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.