Why am I getting "Curl (6) Could not resolve host" after I did a "yum -y update"?

136,493

Solution 1

Try running the command dhclient. I tried it and it worked for me.

Solution 2

As far as I know - this happens due to network adapter type. (Don't know why, just my experiance...) Check your machine's network settings in VirtualBox, search for adapter type. Assuming you are using NAT - select one of Intel's adapters and not other PCI, as many Linux distros doesn't hold the drivers for such adapters, but does have drivers for Intel's adapters. You can always try to bridge the network to bypass that issue. In addition check your proxy just to be sure...

Share:
136,493

Related videos on Youtube

Alex111
Author by

Alex111

Updated on September 18, 2022

Comments

  • Alex111
    Alex111 over 1 year

    I have a CentOS 7.3 machine that is a guest running on Oracle VirtualBox. The host is a Windows machine. I can ping 8.8.8.8 from the Linux server. The Linux server can ping itself by its hostname ping coolvm. As root I recently did a yum -y update command. That is when curl stopped working. FQDNs will not resolve.

    If I try this:

    curl -v http://www.google.com
    

    I get this error:

    • Could not resolve host: www.google.com; Unknown error
    • Closing connection 0 curl: (6) COuld not resolve host: www.google.com; Unknown error

    The commands nslookup, dig and host have not been installed. I cannot install new Yum packages because I get an error related to host resolution ("Resolving time out").

    The /etc/resolv.conf file looks like this:

    # Generated by NetworkManager
    search localdomain
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    

    I tried rebooting the host machine (and thus the guest too). But that did not help me. Browsing the internet has not changed.

    The interface for the main NIC in /etc/sysconfig/network-scripts/ has DNS server stanzas that have worked in the past. The interface file is standard and complete. I have not changed it since the yum -y update command.

    How can I get FQDNs to resolve? I want to use the Lynx command. My repositories rely on FQDNs to resolve. I cannot use yum to install packages.

    Update. I ran this command:

    cat /etc/nsswitch.conf | grep -i hosts
    

    I saw this:

    #hosts:   db files nisplus nis dns
    hosts:    files dns myhostname
    
    • Tim Kennedy
      Tim Kennedy about 7 years
      what does grep ^hosts /etc/nsswitch.conf show you? There should be dns as one of the options. (looks like: hosts: files dns myhostname)
    • Alex111
      Alex111 about 7 years
      It shows hosts: files dns myhostname
  • G-Man Says 'Reinstate Monica'
    G-Man Says 'Reinstate Monica' over 5 years
    Can you explain why this might fix the problem?      Please do not respond in comments; edit your answer to make it clearer and more complete.
  • G-Man Says 'Reinstate Monica'
    G-Man Says 'Reinstate Monica' over 5 years
    Thanks for editing your answer. ISTM that it doesn't make sense that this would be a factor, given that the system was working, and all the user did was a yum -y update. But sometime inexplicable answers work, so let's leave this here and see whether it helps anybody. (Note that Alex111, the original poster, hasn't logged in for over a year, so we aren't likely to hear anything from them.)
  • Amitaysh
    Amitaysh over 5 years
    Great, I just had a similar issue and that solution worked for me... anyway as you can see this was my first answer ever :) so I'm learning. Thanks for the tips!
  • adam-m-hanna
    adam-m-hanna about 4 years
    After trying and failing with many other solutions, yours worked for me. Thank you! :) Now, after spinning in circles for a few hours, I can finally get back to work, ha!
  • Fred
    Fred about 2 years
    I can't install dhclient because I can't resolve any host. So I can't download anything from the package servers.