skillfed

pycares

Python interface for c-ares

pycares v5.0.1 21.3M downloads/30d#1,003 on PyPI183
Permissive license MIT Active released

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 pycares

uv

uv add pycares

poetry

poetry add pycares

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Free Threading :: 3 - StableProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

async DNS resolutionDNS queries pythonc-ares bindingasynchronous name resolutionDNS client librarydomain name lookupnetwork DNS resolver
dns-resolutionasync-networkingc-binding

More Internet packages