brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ALTERNATE_WP_CRON in wp-config helps when loopback requests fail

Wp-Config
~/tips/tip-wp-config-alternate-cron

define( 'ALTERNATE_WP_CRON', true );

Runs scheduled posts on hosts where WordPress cannot call itself.

Scheduled posts stay in the queue forever and Site Health mentions a failed loopback request. Normally WordPress starts its scheduled tasks by calling its own address in the background, and some servers refuse that.

The alternative method avoids the extra call:

define( 'ALTERNATE_WP_CRON', true );

Now, when tasks are due, a visitor’s page request is redirected to the same address with a doing_wp_cron parameter. The browser gets its redirect right away and the same PHP process carries on to run the jobs.

You can check the result without waiting:

wp cron event list

Treat it as a workaround. Visitors may notice that odd parameter in the address bar, analytics can record it, and caching layers or strict clients might react badly to the redirect. It only happens on ordinary GET requests, not on AJAX or XML-RPC calls. A site with no visitors still runs nothing, since a request is still the trigger.

My preference would be to fix the loopback instead: it’s often DNS inside a container resolving the public name wrongly, or a password protection or firewall in front of the site. Failing that, a real system cron calling wp cron event run --due-now every few minutes is dependable and visible. Reach for this constant when you can’t change either of those, as on very restricted hosting.

Further reading: WordPress developer docs: wp-config.php

More Wp-Config tips ls -ld wp-content wp-content/plugins index.php define( 'WP_TEMP_DIR', '/var/www/example.com/tmp' ); define( 'CONCATENATE_SCRIPTS', false ); define( 'CORE_UPGRADE_SKIP_NEW_BUNDLED', true ); wp config list WP_DEBUG All Wp-Config tips (7) All topics

Link