Question

A strange issue with /etc/hosts & DNS name servers in 18.04 droplets

Posted April 6, 2019 4.2k views
WordPressDNSUbuntu 18.04

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 wp_version_check()

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 8.8.8.8
nameserver 8.8.4.4
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.

×
1 answer

In case anyone else runs across this, it looks like this is a bug in systemd that affects 18.04 and 18.10

See https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1624320

Here’s my workaround.

Open /etc/systemd/resolved.conf

Find this section and uncomment the DNS= line

[Resolve]
#DNS=

Then add your DNS servers after the = sign. Using the DNS examples above it would look like this:

[Resolve]
DNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844

Each IP address should be separated by a space according to the systemd docs.

You can find a list of DNS servers here, if you don’t want to use Google’s.

Submit an Answer