Issue with the custom domain when trying to use Let's Encrypt to setup HTTPS

I want to have a custom domain for my custom app in ERPNext. How can I do it?
I have followed the next guides:

  1. Adding Custom Domains to your Site
  2. Setup DNS based Multitenancy
  3. Using Let’s Encrypt to setup HTTPS
  4. Configuring HTTPS

I suppose that the configuration fails when I set the custom domain with the command bench setup add-domain [custom-domain] because, when I try to use the command sudo -H bench setup lets-encrypt [site-name] --custom-domain [custom-domain], I get this error:

Failed authorization procedure. custom.domain.com (http-01): urn:ietf:params:acme:error:dns :: DNS problem: NXDOMAIN looking up A for custom.domain.com

IMPORTANT NOTES:
 - The following errors where reported by the server:

   Domain:  custom.domain.com
   Type:    None
   Details: DNS problem: NXDOMAIN looking up A for
   custom.domain.com

There was a problem trying to setup SSL for your site

What I can be doing wrong?

Is your custom domain live?
And did you point ur custom domains A record to the erpnext server IP ?
Above error says that dns lookup for ur domain failed to get any A record.

Hope this helps.

Your frappe app server must have its own IP address. Say 123.123.123.1
Say your domain name is vazdan.com
If you want your frappe app to resolve at vazdan.com
Your vazdan.com DNS Zone File’s primary A Record must point towards this IP 123.123.123.1
If you have an existing website at vazdan.com (located at say 456.456.456.4) and you want your frappe app to resolve to a subdomain like myapp.vazdan.com You need to add a second A record to your vazdan.com DNS Zone File that points to your frappe app server. Your primary A record points to your website at 456.456.456.4 Then add another A record myapp.vazdan.com with an IP address of 123.123.123.1

On your app server:
From within frappe-bench folder create a site called myapp.vazdan.com