socket.gaierror: [Errno -3] Temporary failure in name resolution
Python couldn't reach a DNS resolver
Seen in Python socket, requests, urllib3, pip, Docker containers
The resolver could not answer at all, usually because the machine or container has no working DNS or network.
Common causes
- No network access, or DNS traffic is blocked (common in containers and CI runners).
- /etc/resolv.conf points to a resolver that is unreachable from here.
- A VPN or Docker network change left DNS misconfigured.
- A brief resolver outage.
How to fix it
- Test resolution from the same place: getent hosts example.com or nslookup example.com.
- Check /etc/resolv.conf and the container or VPN DNS settings.
- Check that outbound UDP and TCP port 53 are allowed.
- Retry with backoff if it is intermittent.
Got a different message? Paste it into the error explainer.
Related errors
- socket.gaierror: [Errno -2] Name or service not known · Python couldn't resolve the hostname
- java.net.UnknownHostException · Java couldn't resolve the hostname
- dial tcp: lookup example.com: no such host · Go couldn't resolve the hostname
- No such host is known · Windows couldn't resolve the hostname
- php_network_getaddresses: getaddrinfo failed · PHP couldn't resolve the hostname
- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed · Python couldn't verify the server's certificate
- certificate verify failed: Hostname mismatch, certificate is not valid for · The certificate doesn't cover this hostname
- Max retries exceeded with url · requests gave up connecting to the URL
- requests.exceptions.ConnectTimeout · Python couldn't open the connection in time
- requests.exceptions.ReadTimeout · The server took too long to respond
- ConnectionRefusedError: [Errno 111] Connection refused · Nothing is listening on that port
- http.client.RemoteDisconnected: Remote end closed connection without response · The server closed the connection without replying