Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Troubleshooting

Cloudflare Tunnel WordPress Not Working: Causes and How to Fix It

Cloudflare Tunnel WordPress Not Working: Causes and How to Fix It

Short answer

WordPress behind Cloudflare Tunnel usually breaks because it receives plain HTTP from cloudflared and keeps redirecting to HTTPS, its site URL still points to a local address, or the tunnel cannot reach the web server. Add HTTPS detection to wp-config, fix the site URLs and check the tunnel's service address.

Key takeaways

  • Tell WordPress about HTTPS using the X-Forwarded-Proto header.
  • Set WordPress URLs to the public tunnel hostname.
  • Use only one layer of HTTPS redirects.
  • A 1033 error means the tunnel is not running.
  • In Docker, point the tunnel at the container name, not localhost.

Why is WordPress not working through Cloudflare Tunnel?

WordPress usually breaks behind Cloudflare Tunnel because it does not know the visitor is on HTTPS, its site URL still points to a local address, or the tunnel cannot reach the web server on the right port.

Cloudflare Tunnel runs a small program called cloudflared on your server. It makes an outbound connection to Cloudflare, and Cloudflare sends visitor traffic down that connection to your local web server. You do not need to open ports, which is why it is popular for home servers and private networks.

The catch is that WordPress sits behind a proxy it does not know about. That causes a predictable set of problems:

  • ERR_TOO_MANY_REDIRECTS in the browser.
  • The site redirects to localhost, a private IP or a different port.
  • Pages load without styles, or show mixed content warnings.
  • wp-admin login loops back to the login screen.
  • Cloudflare error pages such as 502 or 1033.
  • Site Health reports REST API or loopback errors.

Each section below matches one of these symptoms.

Is WordPress stuck in a redirect loop?

A redirect loop usually happens because Cloudflare serves HTTPS to visitors but the tunnel sends plain HTTP to WordPress, so WordPress keeps redirecting to HTTPS.

Here is the chain. The visitor asks for https.

Cloudflare handles the certificate, then cloudflared forwards the request to your origin, often as http://localhost. WordPress sees an http request, thinks it should be https, and redirects. The cycle repeats.

The fix is to tell WordPress the original request was secure. cloudflared adds the X-Forwarded-Proto header, which records the scheme the visitor used. Add this near the top of wp-config.php, above the line that says to stop editing:

if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
    $_SERVER['HTTPS'] = 'on';
}

WordPress describes this approach for reverse proxies in its HTTPS handbook page.

Also check for other things that force HTTPS at the same time:

  • An HTTPS redirect rule in .htaccess or your Nginx config.
  • A plugin such as Really Simple SSL.
  • Cloudflare's Always Use HTTPS setting.

One redirect layer is enough. For general loop fixes, see our guide on fixing too many redirects.

Does the site redirect to localhost or an IP address?

If WordPress sends visitors to localhost or a private IP, the site URL in WordPress still points to the local address, so change it to your public tunnel hostname.

This often happens when you install WordPress locally first, then put it behind a tunnel. WordPress builds every link from its stored address.

To fix it:

  1. Go to Settings > General if you can reach the dashboard.
  2. Set WordPress Address and Site Address to https://your-hostname.
  3. Save.

If you cannot log in, set the address in wp-config.php instead:

define( 'WP_HOME', 'https://example.com' );
define( 'WP_SITEURL', 'https://example.com' );

After that, update old links in content with a search and replace. Our guide on how to search and replace in the WordPress database covers safe tools for that.

Are styles missing or mixed content warnings showing?

Missing styles and mixed content come from WordPress building http links while the page loads over https, which is fixed by the HTTPS detection code and correct site URLs.

When WordPress thinks the request is http, it generates http links for CSS, JavaScript and images. The browser then blocks or warns about them.

Once you add the X-Forwarded-Proto check and set https site URLs, most of these go away. For leftover links stored in posts or theme settings, follow our guide to fixing mixed content warnings.

Clear every cache afterwards, including Cloudflare's. Old cached pages can keep serving broken links.

Is the wp-admin login looping?

A login loop behind a tunnel is usually the same HTTPS detection problem, because WordPress sets secure cookies and then cannot read them on what it thinks is an http request.

Fix HTTPS detection first. Then:

  • Clear your browser cookies for the site.
  • Make sure WP_HOME and WP_SITEURL use the same hostname you visit.
  • Check that Cloudflare is not caching wp-admin or wp-login.php.

If the loop continues, our guides on Cloudflare wp-admin not working and the login page refreshing cover more causes.

Are you seeing a Cloudflare 502 or 1033 error?

A 502 usually means cloudflared cannot reach your web server, while a 1033 error means Cloudflare cannot find a running tunnel for that hostname.

Use this table to narrow it down:

ErrorWhat it usually meansWhat to check
1033Tunnel not running or not connectedIs the cloudflared service running?
502Tunnel runs but cannot reach originService URL, port, web server status
502 with https originTLS check failing on originUse http locally or adjust TLS settings
404 from originWrong host or virtual hostHost header and server name settings

Cloudflare's guide to troubleshooting 1xxx errors explains each code.

For a 502, check the tunnel's public hostname settings. The service should point to where the web server actually listens, such as http://localhost:80.

If you point it at https://localhost with a self-signed certificate, the connection may fail certificate checks. Cloudflare's notes on HTTPS origins with Tunnel cover that case.

Are you running WordPress in Docker?

In Docker, localhost inside the cloudflared container points to that container, not WordPress, so use the WordPress container's service name and internal port instead.

This is a very common setup mistake. If cloudflared runs in its own container, http://localhost:80 goes nowhere.

Instead:

  • Put cloudflared and WordPress on the same Docker network.
  • Point the tunnel service to http://wordpress:80, using your container's service name.
  • Make sure the port matches what the WordPress container listens on internally.

The cloudflared project on GitHub has examples and release notes if you need a specific version.

Do Site Health, cron or updates fail?

WordPress needs to call its own URL for loopback requests and scheduled tasks, so these fail if the server cannot reach its public hostname or Cloudflare Access blocks the request.

When WordPress makes a loopback request, it calls its own public address. Behind a tunnel, that request goes out to Cloudflare and back down the tunnel.

Common blockers:

  • Cloudflare Access in front of the whole hostname. Server requests cannot log in, so they get blocked.
  • DNS on the server that cannot resolve your public hostname.
  • Firewall rules that block outgoing traffic.

If you protect the site with Access, consider applying it only to wp-admin, or add a bypass for requests from the server. Our guide on fixing the REST API error in Site Health explains the checks WordPress runs.

How should Cloudflare settings be set for a tunnel?

Keep Cloudflare settings simple: let the tunnel handle the connection, avoid stacking HTTPS redirects, and bypass the cache for admin and login pages.

Recommended setup:

  • SSL mode: traffic through a tunnel is already encrypted between Cloudflare and cloudflared, so SSL mode matters less than for a normal origin. Avoid adding extra redirects at the origin.
  • Cache rules: bypass cache for wp-admin, wp-login.php and logged-in users.
  • Rocket Loader and similar: turn off if the editor or admin breaks.

For a broader setup, see our guide on how to set up Cloudflare for WordPress.

If the SSL mode is the issue, read our guide to Cloudflare SSL settings for WordPress.

What should you check if it still does not work?

Check the cloudflared logs, test the origin directly from the server, and confirm the hostname, service URL and WordPress addresses all match.

A quick checklist:

  1. Run the tunnel in the foreground and read its log output for connection errors.
  2. On the server, use curl against the service URL to confirm WordPress responds.
  3. Confirm the public hostname in the tunnel config matches your WordPress URLs.
  4. Temporarily disable plugins that handle redirects, SSL or caching.
  5. Check your web server and PHP error logs.

Once the origin responds correctly from the server and the HTTPS detection code is in place, most tunnel problems go away.

Frequently asked questions

Why does Cloudflare Tunnel cause too many redirects in WordPress?

Cloudflare serves HTTPS to visitors but cloudflared often forwards plain HTTP to your server. WordPress sees HTTP and redirects to HTTPS, which loops. Add a check in wp-config that sets HTTPS on when the forwarded protocol header says https.

Should the tunnel point to http or https on my server?

For a web server on the same machine or private network, http is simplest because the tunnel itself is encrypted. If you point it at https with a self-signed certificate, you may need to adjust the tunnel's TLS verification settings.

Can I use Cloudflare Access to protect WordPress behind a tunnel?

Yes, but protecting the whole site can block WordPress loopback requests, cron and REST calls. Many site owners apply Access only to the admin area, or add a bypass rule for requests from the server itself.

Why does my site redirect to localhost after setting up a tunnel?

WordPress still has a local address saved as its site URL. Change WordPress Address and Site Address to your public hostname in Settings, or define them in wp-config, then update old links with a database search and replace.

Sources

  1. HTTPS origins Cloudflare Docs
  2. Troubleshooting Cloudflare 1XXX errors Cloudflare Docs
  3. HTTPS for WordPress WordPress Developer Resources
  4. X-Forwarded-Proto MDN Web Docs
  5. cloudflared GitHub

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.