Edit. Oh, Ben beat me to it. I’ll go ahead and post what I had typed anyway.
To use Let’s Encrypt, you’ll need to use a domain that does have DNS set up. Let’s Encrypt won’t issue a cert for an IP. Let’s Encrypt will only issue a cert after verifying it can access specific content on your site, a process which requires DNS.
In the original issue of this thread, the error was "Verifying staging.mydomain.com...", "staging.mydomain.com verified!", "Verifying 46.101.238.145...", "Traceback.... So, the user had both a domain and IP in site_hosts. With a real domain in the list – which presumably had DNS set up – it was fine to just remove the IP.
When I said…
If you find yourself wanting the site served from the IP, see if this other thread has any helpful info for how to use the domain instead
…that other thread was mostly suggesting how to “use the domain instead” of the IP, serving the staging site from a subdomain staging.example.com.
As an aside I mentioned modifying /etc/hosts but pointed out that doing so only affects the local machine’s ability to view a site at a domain name. It is insufficient as a way to make the Let’s Encrypt process work for a domain without DNS.
So, Let’s Encrypt won’t work for an IP/domain without DNS. If it turns out you’re really just after ssl and have some reason not to set up a domain with DNS, maybe it would work to make the edit in /etc/hosts then set the ssl.provider to self-signed. I haven’t tried this, nor have I taken time to think it through.
So, to be clear, I’d recommend just setting up a domain or subdomain with DNS, instead of modifying your /etc/hosts.