Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

WordPress Site Health "Your site could not complete a loopback request": read the result, then find what blocks the request

Technical article
Hosting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

Site Health in WordPress 6.7.1 shows "Your site could not complete a loopback request" when the web server cannot send a POST request to its own wp-cron.php address and receive HTTP 200. The line under the heading is the useful part. If it starts "The loopback request to your site failed", the request got no HTTP answer at all and an error text and code follow. If it says "unexpected http status code", the server did answer, and the number is the clue.

What the error means

A loopback is a request your site makes to itself. WordPress 6.7.1 sends a POST to site_url( 'wp-cron.php' ) with a 10 second timeout. It passes your own session cookies, adds Basic authentication when the visitor arrived with it, and by default does not verify the certificate (the https_local_ssl_verify filter returns false). The code comments say a POST is used so that wp-cron.php finishes early without running any scheduled event, and wp-cron.php ends at once when the request carries POST data.

The request comes from the server, not your browser. Our own reading: a site can load perfectly for visitors and still fail this test, because the server itself has to resolve and reach its own address.

Site Health explains why it matters: "Loopback requests are used to run scheduled events, and are also used by the built-in editors for themes and plugins to verify code stability." Scheduled events and the theme and plugin editors are the features that rely on it.

Two results exist in the code:

What the screen prints under the heading Status What it means
"The loopback request to your site failed, this means features relying on them are not currently working as expected." then Error: followed by a message and a code in brackets Critical No HTTP answer. The message is the WordPress HTTP error, for a cURL failure it starts cURL error 28:
"The loopback request returned an unexpected http status code, " followed by a number, then "it was not possible to determine if this will prevent features from working as expected." Recommended The server answered with something other than 200

The cURL number is libcurl's. Its list gives 6 as "Could not resolve host", 7 as "Failed to connect() to host or proxy", 28 as "Operation timeout" and 35 as a problem in the SSL/TLS handshake.

Likely causes

The error numbers in the first two rows come from libcurl's list. The explanations of what produces a non-200 answer in the other rows are our own reading; the status number or error code on the screen is what the code prints.

Cause What you see How to confirm
The server cannot resolve or reach its own site address Critical, cURL error 6 or 7, or 28 if the connection attempt stalls The curl test below, run on the server, fails the same way
The answer takes longer than 10 seconds Critical, cURL error 28 The curl test is slow or hangs
The WordPress Address (URL) points somewhere the server cannot use Either result, with the wrong host in the failure Settings > General shows an address that is not where the site lives
A rule, HTTP authentication or a security plugin answers wp-cron.php with 401, 403 or a 5xx Recommended, with that number The curl test shows the same status
A plugin left a PHP session open Site Health also lists "An active PHP session was detected" That entry is on the same Status tab
A redirect or error page replaces wp-cron.php Recommended, a status other than 200 The curl test shows a Location header or an error page

Prove the cause before changing anything

All of these steps only read, apart from the one POST to wp-cron.php, which is the same early-ending request Site Health makes.

  1. Go to Tools > Site Health > Status and expand the entry. Write down the exact error text and the code in brackets, or the HTTP status number.
  2. Look at the same Status tab for "An active PHP session was detected". WordPress.org documents it as a critical issue: a session created by session_start() "interferes with REST API and loopback requests".
  3. On the web server itself, not your own computer, send the same kind of request. The -d option makes curl send a POST, -i shows the response headers, -s with -S keeps errors visible.
curl -sS -i -d 'site-health=loopback-test' https://www.example.com/wp-cron.php

Our own reading: a healthy site returns a status line with 200 and an empty body, because wp-cron.php ends without output. A message about resolving the host, connecting or timing out matches cURL 6, 7 or 28. A 401, 403, 404 or 5xx matches the number on the Site Health screen.

  1. If step 3 fails on the name, try the same request with an address supplied by hand. curl's --resolve option replaces name resolution for that one request.
curl --resolve www.example.com:443:192.0.2.10 -sS -i -d 'site-health=loopback-test' https://www.example.com/wp-cron.php

Our own reading: success here and failure in step 3 means the server's name lookup returns an address it cannot use, and WordPress is not at fault.

  1. Go to Settings > General and compare WordPress Address (URL) with the address you used in steps 3 and 4. WordPress.org says that if the WP_SITEURL constant is defined in wp-config.php, that value appears in the WordPress Address (URL) field, and that if WP_HOME is defined, it appears in the Site Address (URL) field; the screen cannot change either.

Fix

Choose the route that matches what you proved.

The server cannot resolve, reach or time out on its own address

The cure sits in the server's name resolution, firewall or network, not in WordPress. Give the person who manages the server the exact curl output, the error number and the address. Our own advice: ask them to make www.example.com reachable from the server itself, then repeat step 3.

A rule or security plugin returns 401, 403 or a 5xx

The request needs to be allowed from the server's own address. Our own advice: ask whoever manages the firewall, the web server rules or the security plugin to allow a POST to wp-cron.php from the server, and do not switch the rule off for everyone.

To find out whether a plugin is the cause, you would deactivate suspects one at a time. First save the current state: write down the names and status of the active plugins.

wp plugin list --status=active

Also write down the current time.

Risk: the next command deactivates one plugin on the live site. Every feature that plugin provides stops at once, including forms, caching, security rules or a shop if that is what it runs.

wp plugin deactivate example-plugin

Reload Tools > Site Health > Status. If the loopback entry moves to the passed tests, that plugin was the cause.

To undo it, only if you need the plugin back: activate the plugin you wrote down in the list of active plugins. The deactivation is then lost.

Risk: the next command activates the plugin again, so the loopback failure returns if that plugin was the cause.

wp plugin activate example-plugin

Then reload Tools > Site Health > Status and check the loopback entry.

The WordPress Address (URL) is wrong

Save first: write down the current WordPress Address (URL) and Site Address (URL) and the time.

Risk: the next change alters the address WordPress uses for itself. Our own reading: a wrong value can make the login page and every admin screen stop loading, and the loopback request would then fail for a different reason. If a value is defined in wp-config.php, it comes from that file, and the correction is made there instead of on this screen.

Go to Settings > General, enter the correct address in WordPress Address (URL), and save.

To undo it, only if the change made things worse: set the field back to the value you wrote down and save again. The correction is then lost.

Then reload Tools > Site Health > Status and check the loopback entry.

A PHP session is open

WordPress.org's remedy is that the session "should be closed by session_write_close() before making any HTTP requests". That is a change in plugin or theme code, so pass the finding to its developer.

Example (illustrative): on web01, which runs www.example.com, Site Health shows the critical result with Error: cURL error 28: ... under the heading. The curl test in step 3 hangs. The same test with --resolve www.example.com:443:192.0.2.10 returns 200 at once. The administrator concludes that the name lookup on web01 returns an address it cannot connect to, and asks the person who manages the server to correct it. No WordPress setting is touched.

Confirm the fix

  1. Reload Tools > Site Health > Status. The loopback test runs again and the entry should move to the passed tests with the label "Your site can perform loopback requests".
  2. Repeat the curl test from step 3 and expect a 200 status line.

What to watch afterwards

Risks and limits

  • These commands have not been run or lab-tested.
  • The texts and thresholds above come from WordPress 6.7.1. Other versions may word them differently.
  • A passing loopback test shows that one POST to wp-cron.php returned 200. It does not prove that every scheduled event runs.
  • The status number identifies a layer, not a culprit. A 403 may come from the web server, a firewall or a plugin.

Sources