# Error when testing my domain on HTTPS

**URL:** <https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157>\
**Category:** Help\
**Created:** [July 18, 2024, 2:50pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157 "2024-07-18T14:50:14Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mateusjesus](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mateusjesus/32/81482_2.png) [@mateusjesus](https://community.letsencrypt.org/u/mateusjesus)\
**Post date:** [July 18, 2024, 2:50pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/1 "2024-07-18T14:50:14Z")

</div>

I've followed all the steps in the certbot guide, but when I go to test my domain with HTTPS it says ‘connection refused’.

What could this be? Something I haven't configured correctly? I stopped my web application to do the installation and followed this guide using the standalone method: [Certbot Instructions | Certbot](https://certbot.eff.org/instructions?ws=other&os=ubuntufocal)

My domain is: vps48506.publiccloud.com.br

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

The operating system my web server runs on is (include version): Ubuntu 20

I can login to a root shell on my machine: I don't know

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

---

<div class="post-metadata">

**Author:** ![MikeMcQ](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mikemcq/32/52772_2.png) [@MikeMcQ](https://community.letsencrypt.org/u/MikeMcQ)\
**Post date:** [July 18, 2024, 3:54pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/2 "2024-07-18T15:54:06Z")

</div>

> [@mateusjesus](#):
>
> What could this be? Something I haven't configured correctly?  
> My web server is (include version): nginx/1.27.0

Have you configured nginx to handle HTTPS requests?

Because you describe using the "standalone" option which only gets a cert.

You would probably be better off using the `--nginx` option like this

```nohighlight
sudo certbot --nginx -d vps48506.publiccloud.com.br

```

This has two benefits. One is it will create an HTTPS server block in nginx for you. The second is you won't have to stop nginx to renew your cert.

The --standalone option requires exclusive use of port 80 so needs nginx to be stopped to work. Standalone is best when you do not have a web server (like nginx) in use.

---

<div class="post-metadata">

**Author:** ![mateusjesus](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mateusjesus/32/81482_2.png) [@mateusjesus](https://community.letsencrypt.org/u/mateusjesus)\
**Post date:** [July 22, 2024, 4:00pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/3 "2024-07-22T16:00:39Z")

</div>

I got this error when I entered the command you mentioned:

```nohighlight
The nginx plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError("Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.")

```

Is Nginx not installed correctly or is it some configuration I still have to do?

Logs from /var/log/letsencrypt:

```nohighlight
2024-07-22 12:59:24,896:DEBUG:urllib3.connectionpool:http://localhost:None "GET /v2/connections?snap=certbot&interface=content HTTP/1.1" 200 97
2024-07-22 12:59:25,054:DEBUG:certbot._internal.main:certbot version: 2.11.0
2024-07-22 12:59:25,055:DEBUG:certbot._internal.main:Location of certbot entry point: /snap/certbot/3834/bin/certbot
2024-07-22 12:59:25,055:DEBUG:certbot._internal.main:Arguments: ['--nginx', '-d', 'vps48506.publiccloud.com.br', '--preconfigured-renewal']
2024-07-22 12:59:25,055:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#apache,PluginEntryPoint#manual,PluginEntryPoint#nginx,PluginEntryPoint#null,PluginEntryPoint#standalone,PluginEntryPoint#webroot)
2024-07-22 12:59:25,065:DEBUG:certbot._internal.log:Root logging level set at 30
2024-07-22 12:59:25,067:DEBUG:certbot._internal.plugins.selection:Requested authenticator nginx and installer nginx
2024-07-22 12:59:25,067:DEBUG:certbot._internal.plugins.disco:No installation (PluginEntryPoint#nginx): Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.
Traceback (most recent call last):
  File "/snap/certbot/3834/lib/python3.8/site-packages/certbot/_internal/plugins/disco.py", line 112, in prepare
    self._initialized.prepare()
  File "/snap/certbot/3834/lib/python3.8/site-packages/certbot_nginx/_internal/configurator.py", line 204, in prepare
    raise errors.NoInstallationError(
certbot.errors.NoInstallationError: Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.
2024-07-22 12:59:25,067:DEBUG:certbot._internal.plugins.selection:No candidate plugin

```

---

<div class="post-metadata">

**Author:** ![MikeMcQ](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mikemcq/32/52772_2.png) [@MikeMcQ](https://community.letsencrypt.org/u/MikeMcQ)\
**Post date:** [July 22, 2024, 4:23pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/4 "2024-07-22T16:23:24Z")

</div>

> [@mateusjesus](#):
>
> I got this error when I entered the command you mentioned:
> 
> ```nohighlight
> The nginx plugin is not working; ... 
> NoInstallationError("Could not find a usable 'nginx' binary
> 
> ```

How did you install nginx? Because nginx on Ubuntu usually works without trouble

Certbot is saying it could not find an nginx system in its usual location

We can either tell Certbot to use a different location. But, you'd have to know what that is.

Or, we can use the --webroot method. That just needs to know the `root` folder value in the nginx server block for this domain

You said you were using nginx and an nginx is replying to HTTP requests. Can you provide more background on its install method?

> **[Test result for vps48506.publiccloud.com.br: OK](https://letsdebug.net/vps48506.publiccloud.com.br/2126468?debug=y)**
>
> 0 unique issue(s) detected

---

<div class="post-metadata">

**Author:** ![mateusjesus](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mateusjesus/32/81482_2.png) [@mateusjesus](https://community.letsencrypt.org/u/mateusjesus)\
**Post date:** [August 7, 2024, 2:13pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/5 "2024-08-07T14:13:23Z")

</div>

I found my nginx.conf file:

```nohighlight
# Define o usuário e o grupo que o Nginx irá usar
user nginx;

# Define o número de processos de trabalho do Nginx
worker_processes auto;

# Define o local do arquivo de log de erros do Nginx e o nível de log
error_log /var/log/nginx/error.log warn;

# Define o arquivo PID do Nginx
pid /var/run/nginx.pid;

# Configuração do evento do Nginx
events {
    worker_connections 1024;
}

# Configuração do HTTP do Nginx
http {
    # Inclui o mapeamento de tipos MIME padrão
    include /etc/nginx/mime.types;

    # Define o tipo MIME padrão
    default_type application/octet-stream;

    # Define o formato de log principal
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    # Define o local do arquivo de log de acesso do Nginx e o formato de log
    access_log /var/log/nginx/access.log main;

    # Ativa a compressão Gzip
    gzip on;
    gzip_comp_level 6;
    gzip_min_length 1000;
    gzip_types text/plain text/css application/json application/javascript application/xml;

    # Configurações de cache
    client_max_body_size 50m;
    client_body_buffer_size 128k;

    # Define as configurações de roteamento para o React Router
    server {
        # Define a porta HTTP padrão
        listen 80 default_server;
        listen [::]:80 default_server;

        # Define o diretório raiz da aplicação React
        root /usr/share/nginx/html;

        # Define o arquivo padrão a ser servido
        index index.html;

        # Define as regras para lidar com rotas do React Router
        location / {
            try_files $uri $uri/ /index.html;
        }

```

In this case, my nginx is running on behalf of the front-end. I should stop execution and run:

```nohighlight
sudo certbot --nginx -d vps48506.publiccloud.com.br

```

?

---

<div class="post-metadata">

**Author:** ![MikeMcQ](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mikemcq/32/52772_2.png) [@MikeMcQ](https://community.letsencrypt.org/u/MikeMcQ)\
**Post date:** [August 7, 2024, 5:38pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/6 "2024-08-07T17:38:52Z")

</div>

> [@mateusjesus](#):
>
> In this case, my nginx is running on behalf of the front-end. I should stop execution and run?:

You tried that but the place nginx is installed is not the default for Ubuntu. So, Certbot cannot find the nginx executable.

You could use the `--webroot` method instead. That works best with a `--deploy-hook`. What command do you use to reload nginx? I could give example command once know that

Also, having just a single default server block defined in nginx can work. But, usually setting up a server block for each domain (or related domains) is best. You can leave the default there for mis-directed requests. But, better to have dedicated server block for your name.

---

<div class="post-metadata">

**Author:** ![mateusjesus](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mateusjesus/32/81482_2.png) [@mateusjesus](https://community.letsencrypt.org/u/mateusjesus)\
**Post date:** [August 7, 2024, 6:07pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/7 "2024-08-07T18:07:14Z")

</div>

Since I'm using docker for my frontend and backend, I just restart the container to reload or use `sudo systemctl restart nginx`

What would this command look like using --webroot and --deploy-hook?

Would it be something like this?

```nohighlight
sudo certbot --nginx -d vps48506.publiccloud.com.br --webroot --deploy-hook

```

---

<div class="post-metadata">

**Author:** ![MikeMcQ](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mikemcq/32/52772_2.png) [@MikeMcQ](https://community.letsencrypt.org/u/MikeMcQ)\
**Post date:** [August 7, 2024, 6:12pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/8 "2024-08-07T18:12:05Z")

</div>

> [@mateusjesus](#):
>
> Would it be something like this?

No, not like that 🙂 More like this

```nohighlight
sudo certbot --webroot -w /usr/share/nginx/html -d vps48506.publiccloud.com.br 

```

The `-w` folder must match the `root` in the server block for this domain / URI. The folder above matches your default server block because right now that's the only one you have.

After getting a fresh cert you need to reload your nginx container or send a command to your nginx container to reload nginx. When you know that command you add something like

```nohighlight
--deploy-hook 'properCommandToReloadNginx'

```

---

<div class="post-metadata">

**Author:** ![mateusjesus](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mateusjesus/32/81482_2.png) [@mateusjesus](https://community.letsencrypt.org/u/mateusjesus)\
**Post date:** [August 7, 2024, 6:17pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/9 "2024-08-07T18:17:20Z")

</div>

Running this command: `sudo certbot --webroot -w /usr/share/nginx/html -d vps48506.publiccloud.com.br`

I got the following error message: `/usr/share/nginx/html does not exist or is not a directory `

---

<div class="post-metadata">

**Author:** ![MikeMcQ](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mikemcq/32/52772_2.png) [@MikeMcQ](https://community.letsencrypt.org/u/MikeMcQ)\
**Post date:** [August 7, 2024, 6:28pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/10 "2024-08-07T18:28:48Z")

</div>

Oh, right, your nginx is in a container. Sorry.

You need to specify a folder that is available to both where you run Certbot and the nginx container. Setup volumes accordingly.

For example, if you run Certbot in your host make a folder there and use that as the `-w` folder (like `/var/mynginx/certbot`). Then setup a volume in your nginx container to use that for the `root` for any HTTP Challenge requests. Could do something like. Modify the folders and names to suit your container / host.

```nohighlight
server {
    listen 80;
    listen [::]:80; # if using IPv6
    server_name vps48506.publiccloud.com.br;

    location /.well-known/acme-challenge/ {
        root /var/mynginx/certbot; # make/use folder as you prefer
    }
    location / {
       return 301 https://$host$request_uri;
    }
}

```

---

<div class="post-metadata">

**Author:** ![mateusjesus](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mateusjesus/32/81482_2.png) [@mateusjesus](https://community.letsencrypt.org/u/mateusjesus)\
**Post date:** [August 7, 2024, 6:32pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/11 "2024-08-07T18:32:53Z")

</div>

I have a Dockerfile:

```nohighlight
# Imagem do nginx
FROM nginx:latest

# Remove o arquivo de configuração padrão do Nginx
RUN rm /etc/nginx/conf.d/default.conf

# Copia o arquivo de configuração personalizado do Nginx
COPY nginx.conf /etc/nginx/nginx.conf

# Copia os arquivos de build do aplicativo React para o diretório raiz do Nginx
COPY ./app/dist/ /usr/share/nginx/html

```

And docker-compose.yaml:

```nohighlight
version: '3'

services:
  nginx:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "80:80"
    restart: always

```

Those modifications you mentioned would be in my docker-compose.yaml, correct?

---

<div class="post-metadata">

**Author:** ![MikeMcQ](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mikemcq/32/52772_2.png) [@MikeMcQ](https://community.letsencrypt.org/u/MikeMcQ)\
**Post date:** [August 7, 2024, 6:35pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/12 "2024-08-07T18:35:14Z")

</div>

> [@mateusjesus](#):
>
> Those modifications you mentioned would be in my docker-compose.yaml,

I am not a docker expert. I just understand its concepts. There are various ways to define the things. Maybe someone here will offer help but you might need to ask on a docker forum.

A multi-container docker setup requires a lot of care to get right.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/letsencrypt/original/3X/c/a/ca6c06ea1ea201324bba7048c6841ce60236468d.png) [@system](https://community.letsencrypt.org/u/system)\
**Post date:** [September 6, 2024, 6:36pm UTC](https://community.letsencrypt.org/t/error-when-testing-my-domain-on-https/222157/13 "2024-09-06T18:36:05Z")

</div>

Closed on September 6, 2024, 6:36pm UTC

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