Let's encrypt failed because server cannot connect to itself but ok from outside

Hello. I installed Virtualmin on a VPS from Linode, there is no private/internal IP that I know of.

This file can be accessed just fine from outside (open it in any browser and it is ok)
http://www.osmiowater.com/.well-known/acme-challenge/wXRTBsKxMlw88YK5Tkt7zrnI7zeuYrM6PAr8oHd_cIY

But it cannot be access from server itself. Meaning if I use command curl to http://www.osmiowater.com then it shows my default apache page in var/www/html/index.html , not the homepage of this website in home directory of virtualmin.
And that’s likely why Let’s encrypt failed but I don’t know where to look at anymore beside /etc/hosts.
I use external NS servers of Linode for my domain

“I use external NS servers of Linode for my domain”

This is why. During installation of Virtualmin, we set up resolv.conf to use itself as the default name server. That’s to allow things like “Preview website” to work before DNS propagates, but if you’re not using Virtualmin to manage your name service, your local resolver won’t have any records.

So: Edit /etc/resolv.conf, remove “nameserver 127.0.0.1” from the list of name servers (make sure you have at least one name server remaining and that it works for recursive queries.

Thanks Joe. I followed your suggested path and I can confirm it is working now.

To anyone who has the same problem as mine, it doesn’t work right away after I remove 127.0.0.1 from the list. I also had to
_ restart DNS service
_ Remove DNS service for this particular domain and add the service again
_ run post-installation wizard again

You just need to disable the DNS feature in Virtualmin Features and Plugins (you’ll have to disable DNS for all of the Virtual servers that have it enabled, before Features and Plugins will let you turn it off (you can do that with a script using the virtualmin CLI, if you have a lot of domains to change) and re-check configuration. No need to re-run the wizard or restart any services. You can actually stop named once you have disabled it properly in Virtualmin Features and Plugins.