{"id":347,"library":"dnspython","title":"dnspython","description":"dnspython is a comprehensive DNS toolkit for Python, currently at version 2.8.0, supporting Python 3.10 and above. It is actively maintained and follows a regular release cadence.","status":"active","version":"2.8.0","language":"python","source_language":"en","source_url":"https://github.com/rthalley/dnspython","tags":["DNS","networking","Python"],"install":[{"cmd":"pip install dnspython","lang":"bash","label":"Install dnspython"}],"dependencies":[],"imports":[{"note":"Ensure 'dns' is not shadowed by a local module named 'dns'.","symbol":"dns.resolver","correct":"import dns.resolver"},{"note":"Ensure 'dns' is not shadowed by a local module named 'dns'.","symbol":"dns.query","correct":"import dns.query"}],"quickstart":{"code":"import dns.resolver\n\n# Query for A records of 'example.com'\nresult = dns.resolver.resolve('example.com', 'A')\nfor ipval in result:\n    print('IP', ipval.to_text())","lang":"python","description":"This script queries the A records for 'example.com' and prints each IP address."},"warnings":[{"fix":"Update your code to align with the new function signatures and behaviors as per the dnspython 2.0.0 release notes.","message":"In dnspython 2.0.0, the 'dns.query' module was refactored, leading to changes in function signatures and behavior. Review the changelog for detailed migration steps.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Rename your script to a different name to prevent import conflicts.","message":"Avoid naming your script 'dns.py' to prevent import conflicts with the dnspython library.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'2.8.0':13 '3.10':16 'activ':21 'cadenc':28 'comprehens':5 'current':10 'dns':6,29 'dnspython':1,2 'follow':24 'maintain':22 'network':30 'python':9,15,31 'regular':26 'releas':27 'support':14 'toolkit':7 'version':12","created_at":"2026-03-28T10:51:33.608271+00:00","updated_at":"2026-04-16T14:38:20.128510+00:00","problems":[{"fix":"Install the `dnspython` package using pip: `pip install dnspython`","cause":"The `dnspython` package, which provides the `dns` module, is not installed in the Python environment, or the environment where it's installed is not the one being used.","error":"ModuleNotFoundError: No module named 'dns'"},{"fix":"Change your import statement from `import dnspython` to `import dns` (or more specifically, `import dns.resolver`, `import dns.message`, etc., depending on what you need).","cause":"Developers often try to import `dnspython` using `import dnspython`, but the primary module to import from the `dnspython` package is `dns` (e.g., `import dns.resolver`).","error":"ModuleNotFoundError: No module named 'dnspython'"},{"fix":"Verify the domain name for typos. If the name is correct, try configuring the resolver to use different or public nameservers (e.g., Google's 8.8.8.8) using `resolver = dns.resolver.Resolver(); resolver.nameservers = ['8.8.8.8']` or explicitly checking different nameservers.","cause":"This error occurs when the queried domain name does not exist according to the configured DNS nameservers. This can be due to a typo in the domain, the domain truly not existing, or issues with the nameservers being used.","error":"dns.resolver.NXDOMAIN: None of DNS query names exist"},{"fix":"Catch the `dns.resolver.NoAnswer` exception in a `try-except` block to handle cases where no record of the specified type is found. Alternatively, when using `resolver.query()`, set `raise_on_no_answer=False` if you want to inspect the response even if no answer section is present.","cause":"This exception is raised when the queried domain name exists, but there is no DNS record of the specific type requested (e.g., asking for an MX record where only A records exist).","error":"dns.resolver.NoAnswer"},{"fix":"Increase the `lifetime` and/or `timeout` parameters for your resolver. For example: `resolver = dns.resolver.Resolver(); resolver.timeout = 5; resolver.lifetime = 10`. Also, ensure that your network configuration allows DNS queries to the target nameservers.","cause":"The DNS query or the overall resolution process took longer than the specified `lifetime` or `timeout` setting, meaning no response was received from any nameserver within the allotted time. This often indicates network issues, slow DNS servers, or restrictive firewall rules.","error":"dns.resolver.LifetimeTimeout: The resolution lifetime expired"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"2.8.0","cli_name":"dnspython","cli_version":"sh: 1: dnspython: not found","type":"library","homepage":"https://www.dnspython.org","github":"https://github.com/rthalley/dnspython","docs":"https://dnspython.readthedocs.io/en/stable/","changelog":null,"pypi":"https://pypi.org/project/dnspython/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":"verified"}}