Note

Python’s dnspython module refuses to read /etc/resolv.conf, so to
access hostnames that are not served up via DNS, such as the extremely common
case of localhost, you may need to install a package like dnsmasq to act
as a local DNS server for those hostnames.