Skip to content
MtrXTools

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

  1. Test resolution from the same place: getent hosts example.com or nslookup example.com.
  2. Check /etc/resolv.conf and the container or VPN DNS settings.
  3. Check that outbound UDP and TCP port 53 are allowed.
  4. Retry with backoff if it is intermittent.
Check the name resolves publicly

Got a different message? Paste it into the error explainer.

Related errors

All 32 Languages & runtimes errors