curl: Could not resolve host: www.baidu.com;

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了curl: Could not resolve host: www.baidu.com;相关的知识,希望对你有一定的参考价值。

今天,在执行curl时,突然发现这个报错,问题是之前完全没有出现过这样的情况。


[[email protected] ~]# curl www.baidu.com

curl: (6) Could not resolve host: www.baidu.com; 未知的错误

上网了解了一下,都说是DNS的问题,因此修改一下DNS配置


[[email protected] ~]# vim /etc/resolv.conf

[[email protected] yum.repos.d]# cat /etc/resolv.conf 

# Generated by NetworkManager

# No nameservers found; try putting DNS servers into your

# ifcfg files in /etc/sysconfig/network-scripts like so:

#

# DNS1=xxx.xxx.xxx.xxx

# DNS2=xxx.xxx.xxx.xxx

# DOMAIN=lab.foo.com bar.foo.com

nameserver 114.114.114.114            #添加DNS

nameserver 8.8.8.8


结果只是加上了nameserver 114.114.114.114就可以了,网上了解到的可能是电信DNS有调整的缘故,但是具体的原因还是不得而知。


以上是关于curl: Could not resolve host: www.baidu.com;的主要内容,如果未能解决你的问题,请参考以下文章

BUG YII2.0 cURL error 6: Could not resolve host:

14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"

window是怎么用curl啊,好像只能用双引号 单引号提示 Could not resolve host

LinuxCould not resolve: www.test.com (Could not contact DNS servers)

Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac‘ Could not resolve all

Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac‘ Could not resolve all