Could not resolve host: Centos 7

Solution 1:

Could not resolve host:; Unknown error

This indicates that you either (a) don't have a properly configured DNS server or (b) your network configuration isn't correct and you can't connect to a DNS server to check the hostname

Try using ping If this fails, try ping <local-gateway-ip>. If that also fails, your local network configuration is wrong and you'll have to check the configuration.

If you can ping, try using host, nslookup or dig to check the DNS settings like host or dig If these fail, you need to check your DNS settings. Check /etc/resolv.conf to see what's configured.


Since /etc/resolv.conf is blank, you need to setup a DNS resolver. I would suggest entering the following into the file using nano or vi (or whatever your comfortable using):


Save this file, then try yum update again.

You can also try other DNS hosts if you would rather, such as or or any of the OpenDNS hosts.

Solution 2:

You may have a connectivity issue somewhere, here a small process to check where you have an issue.

Basic Connectivity

Check if the server has internet (ip address and correct route - if not working, check with ip address if you have an IP address).



Check what are the resolver and ping them

 cat /etc/resolv.conf

You should have line with nameserver and an IP address. Check that IP is answering.

 ping xx.xx.xx.xx

Then do an nslookup


It should return a list of IP addresses. If not, your DNS server might not working correctly, you can try another server with

 > server

And check this time it's working as expected.