腾讯云 gaierror: Temporary failure in name resolution错误解决

今天中午看图猜话小程序的demo刚上线,告警群里就开始没完没了的报告脚本错误(此处略去心中一万句mmp…

问题:

看了一下uwsgi.log发现如下错误没有规律的间歇性出现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Internal Server Error: /
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 57, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/local/lib/python3.7/socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 301, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 168, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f201d4460b8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution
................

解决:

Temporary failure in name resolution这句话看上去是在说DNS解析有问题,百度了一下发现有人在使用腾讯云时遇到类似错误,参照他的解决方案,问题解决,具体操作如下:

sudo vi /etc/resolv.conf, 发现里面只有一条 nameserver 127.0.0.53 然而 /etc/resolvconf/resolv.conf.d/base 里面有俩条记录,手动把这俩条记录加到 /etc/resolv.conf 就正常了。

目前问题暂时解决。

参考资料: https://low.bi/p/azd1wpBgZJl https://www.cnblogs.com/ruigu/p/8603247.html


腾讯云 gaierror: Temporary failure in name resolution错误解决
https://blog.yrpang.com/posts/25327/
作者
yrPang
发布于
2019年4月9日
许可协议