python
network_error
ai_generated
true
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.internal:443 ssl:default [Name or service not known]
ID: python/aiohttp-cannot-connect-to-host-name-not-known
80%Fix Rate
85%Confidence
0Evidence
2024-08-19First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
Root Cause
DNS resolution failed for the hostname; inside containers this often means the resolver config (/etc/resolv.conf) or the hostname itself is wrong, or async DNS is blocked.
generic中文
主机名的 DNS 解析失败;在容器中通常意味着解析配置(/etc/resolv.conf)或主机名本身有误,或者异步 DNS 被阻止。
Workarounds
-
90% success
import socket socket.getaddrinfo('api.internal', 443) # test from Python # then: cat /etc/resolv.conf and ensure the nameserver is reachable -
82% success
try: import aiodns conn = aiohttp.TCPConnector(resolver=aiohttp.AsyncResolver()) except ImportError: conn = aiohttp.TCPConnector() # default ThreadedResolver
Dead Ends
Common approaches that don't work:
-
90% fail
The failure is DNS, not TLS; disabling SSL has no effect on name resolution.
-
85% fail
Resolution fails immediately with NXDOMAIN; waiting longer does not help.