Caddy module: dns.providers.cloudflare

Clone this repo:


  1. 91cf700 readme: Add troubleshooting section (#29) by Brennan Kinney · 1 year, 6 months ago master
  2. 8ea1cff go.mod: Use Caddy v2.4.0 stable by Matthew Holt · 1 year, 7 months ago
  3. 964e47d go.mod: Use caddy v2.4.0-beta.2 by Matthew Holt · 1 year, 8 months ago
  4. 9d3a897 Update environment variable name in (#20) by Jerome Leclanche · 1 year, 9 months ago
  5. 728f5b6 Upgrade dependencies by Matthew Holt · 1 year, 9 months ago

Cloudflare module for Caddy

This package contains a DNS provider module for Caddy. It can be used to manage DNS records with Cloudflare accounts.

Caddy module name


Config examples

To use this module for the ACME DNS challenge, configure the ACME issuer in your Caddy JSON like so:

	"module": "acme",
	"challenges": {
		"dns": {
			"provider": {
				"name": "cloudflare",
				"api_token": "{env.CF_API_TOKEN}"

or with the Caddyfile:

tls {
	dns cloudflare {env.CF_API_TOKEN}

You can replace {env.CF_API_TOKEN} with the actual auth token if you prefer to put it directly in your config instead of an environment variable.


See the associated README in the libdns package for important information about credentials.

NOTE: If migrating from Caddy v1, you will need to change from using a Cloudflare API Key to a scoped API Token. Please see link above for more information.


Error: Invalid request headers

If providing your API token via an ENV var which is accidentally not set/available when running Caddy, you'll receive this error from Cloudflare.

Double check that Caddy has access to a valid CF API token.

Error: timed out waiting for record to fully propagate

Some environments may have trouble querying the _acme-challenge TXT record from Cloudflare. Verify in the Cloudflare dashboard that the temporary record is being created.

If the record does exist, your DNS resolver may be caching an earlier response before the record was valid. You can instead configure Caddy to use an alternative DNS resolver such as Cloudflare's official

Add a custom resolver to the tls directive:

tls {
  dns cloudflare {env.CF_API_TOKEN}

Or with Caddy JSON to the acme module: challenges.dns.provider.resolvers: [""].