pycares
Python interface for c-ares
What it is and what it does
pycares is a Python binding to c-ares, a C library that performs DNS resolution asynchronously. It wraps c-ares to allow Python code to make non-blocking DNS queries for A, AAAA, MX, and other record types. The package bundles c-ares as a submodule by default, though you can use a system-provided c-ares library by setting the PYCARES_USE_SYSTEM_LIB environment variable during build.
The package supports Python 3.9 and later on CPython and PyPy, with prebuilt wheels for Windows, macOS, and Linux. It can be used programmatically from Python code or directly from the command line with a dig-like interface. Optional IDNA 2008 support is available by installing the idna package alongside it.
Use it for:
- Perform non-blocking DNS lookups in async applications without blocking the event loop
- Resolve multiple domain names concurrently in network tools or web scrapers
- Query specific DNS record types (MX, NS, SRV) for mail server or service discovery
- Use as a CLI tool similar to dig for quick DNS queries from the command line
- Build DNS-dependent services that need fine-grained control over resolution behavior
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pycares provides a Python interface to c-ares, a C library for asynchronous DNS requests and name resolution.
Yes, if you need asynchronous DNS resolution in Python. pycares is actively maintained, has no known vulnerabilities, supports modern Python versions, and offers broad platform coverage via prebuilt wheels. The medium install friction (compiled extension) is offset by the availability of wheels. Install only if your application genuinely requires non-blocking DNS queries; the standard library's socket module is sufficient for most synchronous use cases.
Install
pycares on PyPI
pip
pip install pycaresuv
uv add pycarespoetry
poetry add pycaresInstalling pycares
Before you install
Medium install friction due to compiled extension (cffi dependency). Active maintenance with recent commits and broad platform coverage via prebuilt wheels for CPython 3.9–3.14 and PyPy.
License in practice
MIT license permits unrestricted use, modification, and distribution in commercial and private projects.
Quickstart
pip install pycares
import pycares
# Query A records for a domain
resolver = pycares.Resolver()
resolver.query('example.com', pycares.QUERY_TYPE_A)
Requires cffi and a C compiler or prebuilt wheels for your platform. Tests require internet access for real DNS queries.
Verify before relying
- Whether async/await patterns are directly supported or only callback-based API
- Performance characteristics compared to standard library socket.getaddrinfo()
- Whether bundled c-ares submodule is kept in sync with upstream security patches
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — cffi |
| Maintenance | actively maintained — 225 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 21,344,113/month — #1,003 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pycares-5.0.1-cp310-cp310-macosx_10_9_x86_64.whl; pycares-5.0.1-cp310-cp310-macosx_11_0_arm64.whl; pycares-5.0.1-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; pycares-5.0.1-cp310-cp310-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl; pycares-5.0.1-cp310-cp310-manylinux_2_26_s390x.manylinux_2_28_s390x.whl; pycares-5.0.1-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl; pycares-5.0.1-cp310-cp310-musllinux_1_2_aarch64.whl; pycares-5.0.1-cp310-cp310-musllinux_1_2_ppc64le.whl; pycares-5.0.1-cp310-cp310-musllinux_1_2_s390x.whl; pycares-5.0.1-cp310-cp310-musllinux_1_2_x86_64.whl; pycares-5.0.1-cp310-cp310-win_amd64.whl; pycares-5.0.1-cp310-cp310-win_arm64.whl; pycares-5.0.1-cp311-cp311-macosx_10_9_x86_64.whl; pycares-5.0.1-cp311-cp311-macosx_11_0_arm64.whl; pycares-5.0.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; pycares-5.0.1-cp311-cp311-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl; pycares-5.0.1-cp311-cp311-manylinux_2_26_s390x.manylinux_2_28_s390x.whl; pycares-5.0.1-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl; pycares-5.0.1-cp311-cp311-musllinux_1_2_aarch64.whl; pycares-5.0.1-cp311-cp311-musllinux_1_2_ppc64le.whl
Tags
More Internet packages
Botocore provides low-level, data-driven access…
permissive · top 100 on PyPI
aiobotocoreProvides an async client for AWS services using…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
googleapis-common-protosProvides common Protocol Buffer message…
permissive · top 100 on PyPI
aiodnsProvides asynchronous DNS resolution for…
permissive · top 5,000 on PyPI
dnspythondnspython is a DNS toolkit that handles…
permissive · top 1,000 on PyPI
nslookupProvides high-level DNS lookups (A, AAAA, and…
copyleft · top 15,000 on PyPI
dnslibEncodes and decodes DNS wire-format packets,…
permissive · top 5,000 on PyPI
apeye-coreProvides core offline URL and domain handling…
permissive · top 5,000 on PyPI
aiohttp-asyncmdnsresolverProvides an async resolver for aiohttp that…
permissive · top 15,000 on PyPI
google-cloud-dnsPython client library for Google Cloud DNS API…
permissive · top 15,000 on PyPI
idna_sslPatches Python's ssl.match_hostname to support…
permissive · top 15,000 on PyPI
adguardhomeAsynchronous Python client library for…
permissive · top 15,000 on PyPI