Question

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 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?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted 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.

This comment has been deleted

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Become a contributor for community

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    DigitalOcean Documentation

    Full documentation for every DigitalOcean product.

    Resources for startups and SMBs

    The Wave has everything you need to know about building a business, from raising funding to marketing your product.

    Get our newsletter

    Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

    New accounts only. By submitting your email you agree to our Privacy Policy

    The developer cloud

    Scale up as you grow — whether you're running one virtual machine or ten thousand.

    Get started for free

    Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

    *This promotional offer applies to new accounts only.