Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
A strange issue with /etc/hosts & DNS name servers in 18.04 droplets
A few days ago I created two new droplets with Ubuntu 18.04.
Both of these droplets have identical setups. I provisioned each with the same Ansible playbooks.
One of them is dedicated to Wordpress. Yesterday when performing a health check I saw that the REST API was unavailable and the loopback connection wasn’t working. In addition, it reported that a plugin had deactivated
I know that this wasn’t a plugin issue, as it affected all of the WP sites on this droplet. I confirmed by using troubleshoot mode and by manually disabling all plugins.
The errors was associated with a curl error:
curl: (6) Could not resolve hostname: domain.com
Ping, nslookup, and wget all gave similar errors for any locally hosted domains. Unable to resolve the hostname. All worked as expected for any non-local domain.
This was not the case on the other, identical, droplet. Curl, wget, etc. all worked as expected for local and non-local domains.
After spending the evening trying all the fixes I could find, they were either inapplicable or just didn’t work.
A moment ago I found this answer on Ask Ubuntu https://askubuntu.com/a/512311
/etc/resolv.conf contained the following on both droplets:
nameserver 127.0.0.53 options edns0
On the affected droplet, I changed the DNS name servers according to the Ask Ubuntu post:
nameserver 22.214.171.124 nameserver 126.96.36.199 nameserver 2001:4860:4860::8888 nameserver 2001:4860:4860::8844 options edns0
…and just like that, problem solved.
I’m not too fussed about this as long as it’s working. But it is something that needs a long term fix.
Does anyone have any idea why the DNS name servers would work on one droplet and fail completely for local hostnames on another with identical specs?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×