when I try to load a web page to terminal it gives curl: (6) Could not resolve host
error.
I have internet in my PC and trying from my home internet connection. So as I there is no any proxy involve here.
[root@localhost kevin]# curl http://google.com
curl: (6) Could not resolve host: google.com; Name or service not known
clean all
and tried again but no lucky.
But if I use IP instead of the domain name, it works fine.
[root@localhost kevin]# curl http://173.194.46.0
any clue please?
Perhaps you have some very weird and restrictive SELinux rules in place?
If not, try
strace -o /tmp/wtf -fF curl -v google.com
and try to spot from/tmp/wtf
output file what's going on.Try nslookup google.com to determine if there's a DNS issue. 192.168.1.254 is your local network address and it looks like your system is using it as a DNS server. Is this your gateway/modem router as well? What happens when you try ping google.com. Can you browse to it on a Internet web browser?
We had the same problem on our Linux Server and we just restarted PHP as well as Apache. We believe that some DNS cache inside curls was wrong and just restarting PHP solved this.
I had the same problem, except on an Ubuntu VM. Turns out my wifi had disconnected. I didn't think to check at first because my host's (Windows 10) internet had been working just fine. So all I had to do was reconnect the internet.
I have today similar problem. But weirder.
host pl.archive.ubuntu.com
dig pl.archive.ubuntu.com
,dig @127.0.1.1 pl.archive.ubuntu.com
Revelation
Eventually I used
strace
on curl and found that it was connection tonscd
deamon.Solution
I've restarted the nscd service (Name Service Cache Daemon) and it helped to solve this issue!
Issues were:
Here is how I fixed it:
IPV6 Disabling
su
and enter to log in as the super usercd /etc/modprobe.d/
to change directory to/etc/modprobe.d/
vi disableipv6.conf
to create a new file thereEsc + i
to insert data to fileinstall ipv6 /bin/true
on the file to avoid loading IPV6 related modulesEsc + :
and thenwq
for save and exitreboot
to restart fedoralsmod | grep ipv6
Add Google DNS server
su
and enter to log in as the super usercat /etc/resolv.conf
to check what DNS server your Fedora using. Mostly this will be your Modem IP address.8.8.8.8
and8.8.4.4
. But in future those may change.vi /etc/resolv.conf
to edit theresolv.conf
fileEsc + i
for insert data to fileType below two lines in the file
nameserver 8.8.8.8
nameserver 8.8.4.4
-Type
Esc + :
and thenwq
for save and exitHere is my blog post about this: http://codeketchup.blogspot.sg/2014/07/how-to-fix-curl-6-could-not-resolve.html