I used to have a very slow DNS lookup on my Ubuntu machine when connecting through a single modem / ISP. I followed the instructions (for example, here ) to use permanent DNS caching, so I do not repeat repeated DNS queries, and everything became much faster. However, I noticed that when pulling / clicking on repositories at the mercury level it was very slow even tolerate very small changes. Looking deeper, I found that _socket.getaddrinfo , that is, DNS _socket.getaddrinfo , was busy all the time. Why all web browsers use the information in /etc/pdnsd.conf to use old dns requests, this is not the case for python sockets. How can I use mercury to use cached queries?
Update
It is also possible that getaddrinfo tries to get both ipv4 and ipv6 addresses and returns a response only after it could not find the ipv6 address. I am not sure how to check this, that is, regardless of whether the delay is related to ipv6, inconsistency, or both.
Update
This may be due to ipv6 requests, as suggested in the answer here , I will need to check as soon as I get a chance.
source share