Skip to content

Cloudflare R2

Before you begin

A Cloudflare account with R2 enabled.

For broader planning context before connecting a live site, see How to Offload WordPress Media to Cloudflare R2. If you are deciding between providers, see Cloudflare R2 vs Amazon S3 for WordPress Media. For product catalogs, see Cloudflare R2 for WooCommerce product images.

Steps

  1. Cloudflare dashboard → R2 → create a bucket.
  2. R2 → Manage API tokens → create a token with Object Read & Write scoped to that bucket; copy the Access Key ID and Secret Access Key.
  3. In Universal Storage → Settings: choose provider preset Cloudflare R2, enter your bucket name, set Region to auto, set Endpoint to https://<account-id>.r2.cloudflarestorage.com, and enable Force Path Style.
  4. Enter the Access Key ID / Secret Access Key from step 2, then Test connection.

Public delivery

For a production site, connect a custom domain to your R2 bucket:

  1. In Cloudflare, open the bucket’s Settings → Custom Domains → Add and connect a media hostname such as media.example.com. The domain must be in the same Cloudflare account as the bucket.
  2. Wait for the domain status to become Active.
  3. In Universal Storage → Storage, set the profile’s CDN/Base URL to that HTTPS address, for example https://media.example.com.

The r2.cloudflarestorage.com endpoint is for S3 API access, not your public media URL. Cloudflare’s public r2.dev address is rate-limited and intended for development only. For production, connect the custom domain through R2; do not point a CNAME at r2.dev. See Cloudflare’s public bucket documentation.

Verify it worked

  1. Test connection passes all steps.
  2. Follow Your first upload and confirm the test image and its generated sizes appear in the R2 bucket.
  3. Open the uploaded image’s full public URL in a browser. Test an actual object URL, not just the domain root; R2 does not list bucket contents at the root.
  4. Enable Serve from S3 under Universal Storage → Settings, then check a page containing the test image. Confirm that the image and thumbnails load from the configured delivery host.

A successful connection test checks storage access; it does not prove that public delivery works. Complete both checks before migrating your existing library.

Troubleshooting

Connection fails — double-check the endpoint includes your Cloudflare account ID and that Force Path Style is enabled; R2 requires it.

The upload succeeds but the image does not load — check that the custom domain is active and the profile’s CDN/Base URL matches it. Open the exact object URL directly, then follow Missing / broken files.

Cross-provider migration between Amazon S3 and Cloudflare R2, with verify-before-switch safety, is a Pro capability.