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:

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

/etc/resolv.conf contained the following on both droplets:

options edns0

On the affected droplet, I changed the DNS name servers according to the Ask Ubuntu post:

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


Here’s my workaround.

Open /etc/systemd/resolved.conf

Find this section and uncomment the DNS= line


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

DNS= 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

    Featured on Community

    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

    Become a contributor

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

    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

    Learn more
    DigitalOcean Cloud Control Panel