<urlopen error [Errno -3] Temporary failure in name resolution>问题解决

4,885 阅读1分钟

直接解决方案

这还在写发送企业微信脚本时候遇到的,解析URL是发生了失败,推测是DNS配置原因。ping了一个外部的ip地址,正常,但ping一个外部的url,发现 the host is unknow,可以断定是DNS的设置有问题。

于是修改/etc/resolv.conf

增加两行(有时DNS地址是咨了服务器运营商得知的)

nameserver 8.8.8.8

nameserver 114.114.114.114

再执行service network restart重启网络服务即可(大部分情况下不需要重启就可以生效)