A high-performance, CLI-driven DNS record invalidation tool that sends purge requests to Cloudflare’s 1.1.1.1 API. Designed to invalidate cached DNS records for a domain across multiple record types.
This tool is ideal for:
- Clearing out stale DNS entries (e.g., after migrations or TTL overrides)
- Automating cache purges for CI/CD, incident response, or bulk record updates
- Programmatic, scriptable DNS workflows
Python 3.7+ is required.
- Clone the repo:
git clone https://github.com/DanHouseman/cloudflare-dns-purge.git
cd cloudflare-dns-purge- Install via pip:
pip install .This registers cloudflare-dns-purge as a global command-line tool.
pip install -r requirements.txt
python cloudflare-dns-purge.py <domain> [options]Once installed with pip install ., you can use:
cloudflare-dns-purge example.com --types A AAAA --verbose --exportThis behaves exactly like calling python cloudflare-dns-purge.py, but works globally from any directory.
- Clone the repo or download the script:
git clone https://github.com/DanHouseman/cloudflare-dns-purge.git
cd cloudflare-dns-purge- Install dependencies:
pip install -r requirements.txtpython cloudflare-dns-purge.py <domain> [options]domain: The fully-qualified domain to purge (e.g.example.com)
| Option | Description |
|---|---|
--types |
Space or comma-separated list of DNS record types (e.g., A AAAA CNAME) |
--delay |
Delay (in seconds) between requests or submissions |
--threads |
Number of concurrent threads (default: 1) |
--verbose |
Enable verbose per-record logging |
--export |
Export results to purge_log_<domain>.json or .csv |
A, AAAA, CAA, CNAME, DNSKEY, DS, HTTPS, LOC, MX, NAPTR, NS, PTR, SPF, SRV, SVCB, SSHFP, TLSA, TXT
python cloudflare-dns-purge.py example.compython cloudflare-dns-purge.py example.com --types A AAAA CNAMEpython cloudflare-dns-purge.py example.com --types A AAAA --threads 4 --delay 0.3 --verboseWhen combining --threads and --delay, it’s important to understand how the script behaves:
| Mode | Behavior |
|---|---|
--threads 1 |
--delay is applied after each request (safe throttling). |
--threads > 1 |
--delay is applied between task submissions, not within each thread. |
--delay negative |
Treated as 0. No actual delay will be enforced. |
--threads < 1 |
Treated as 1 (single-threaded). |
- Single-threaded mode ensures each purge is spaced out to avoid overwhelming the API.
- Multithreaded mode allows parallel execution, but without
--delay, it can burst too fast. --delayin threaded mode spaces submission, not execution.
If you're purging more than ~5 records and want to avoid hitting rate limits:
python cloudflare-dns-purge.py example.com --types A AAAA CNAME TXT --threads 4 --delay 0.3 --verboseThis uses controlled concurrency and avoids overwhelming the 1.1.1.1 purge API.
python cloudflare-dns-purge.py example.com --types A,AAAA --export # exports JSON
python cloudflare-dns-purge.py example.com --types A,AAAA --export csv # exports CSV[✅ SUCCESS] A → purge request queued. Please wait a few seconds...
[❌ FAILURE] TXT → {"msg":"invalid record type"}=== SUMMARY ===
✅ Successes: 2 → A, AAAA
❌ Failures: 1
- TXT → {"msg":"invalid record type"}purge_log_example.com.json:
{
"domain": "example.com",
"successes": [
{"type": "A", "status": "SUCCESS", "message": "purge request queued"},
{"type": "AAAA", "status": "SUCCESS", "message": "purge request queued"}
],
"failures": [
{"type": "TXT", "status": "FAILURE", "message": "invalid record type"}
]
}purge_log_example.com.csv:
Type,Status,Message
A,SUCCESS,purge request queued
AAAA,SUCCESS,purge request queued
TXT,FAILURE,invalid record type- The API must include in its return
"purge request queued"to be considered a success. - Invalid or unsupported record types will be rejected before sending.
- You may need to wait several seconds for DNS propagation to complete after the purge.