无法建立新连接:[Errno 3]python请求中的名称解析暂时失败

2024-04-28 21:58:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我偶尔会收到请求中的名称解析错误,大约每20个请求中就会发生一次

我已经和请求域服务提供商联系过了,他们说它可以和其他客户一起使用

我不确定这是否是因为系统级别的DNS解析。我正在数字海洋上运行一个ubuntu实例

让我知道是否有人像我一样(偶尔)遇到过这个问题

请找到堆栈跟踪

gaierror: [Errno -3] Temporary failure in name resolution
  File "urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "urllib3/util/connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "python3.7/socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f53b0d24790>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution
  File "urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "urllib3/connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "urllib3/connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "urllib3/connection.py", line 301, in connect
    conn = self._new_conn()
  File "urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
MaxRetryError: HTTPSConnectionPool(host='demo.api.*****.com', port=7890): Max retries exceeded with url: /api/bank/find (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f53b0d24790>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
  File "requests/adapters.py", line 449, in send
    timeout=timeout
  File "urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
ConnectionError: HTTPSConnectionPool(host='demo.api.*****.com', port=7890): Max retries exceeded with url: /api/bank/find (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f53b0d24790>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))



Tags: nameinpyselfhostnewfailureport