Most Rank Math problems belong to one of its modules, not to the plugin as a whole. A sitemap that returns 404 is usually missing its rewrite rules, either because WordPress needs its permalinks flushed or because the site runs on Nginx, which ignores .htaccess. An empty Analytics screen is almost never a plugin bug. It is one of four things: the Google connection lost its token, the rank_math/analytics/ scheduled events are not running because WP-Cron is disabled, the wp_rank_math_analytics_* tables did not survive a migration, or the Search Console property you connected does not own your URLs. Rank Math wraps roughly fourteen modules that you can switch on and off separately, and each one owns its own tables, scheduled events, cache and front-end output. The steps below walk the modules that actually break, in the order they break, with the commands that show which one you are looking at.
What you’ll accomplish
- A working Analytics module, or a definite answer about which of its four break points is the one failing on this site.
- A 404 Monitor that is either bounded and useful or switched off and truncated, instead of a table quietly growing past a million rows.
- A sitemap that reflects what you published five minutes ago, with the caching layer that was hiding it identified by name.
- Exactly one JSON-LD graph per page, with the duplicate emitter — Rank Math’s or the theme’s — turned off deliberately rather than left to compete.
- A short WP-CLI check you can rerun after every plugin update to confirm none of the above quietly regressed.
Prerequisites
- WordPress 6.0 or newer, PHP 8.0 or newer, and a recent Rank Math (free or PRO). Menu paths move between minor releases; the option names and table names below do not.
- WP-CLI on the host and a database user that can read
information_schema. All of this is possible in wp-admin, but the admin screens hide exactly the state you need to see. - Shell access with
curl. Several checks only mean anything from outside a logged-in browser session, because admin requests bypass the page cache. - Your real table prefix.
wp_is the documented default and plenty of installs do not use it. Runwp db prefixonce and substitute yours everywhere below. - A verified Search Console property before you touch the Analytics module. If you do not have one yet, start with Search Console setup for WordPress.
- The ability to purge whatever page cache and CDN sit in front of PHP. LiteSpeed Cache, WP Rocket, Varnish and Cloudflare all happily cache sitemap XML.
- A staging copy for the schema and redirection work. Both become visible to Google within days and are awkward to reverse once crawled.
How it works
Rank Math installs as a single plugin directory, but very little of it loads unconditionally. The rank_math_modules option holds an array of the module slugs that are switched on, and the plugin registers a module’s hooks, admin screens, REST routes and scheduled events only if its slug appears in that array. Switching a module off in the dashboard removes its code from the request entirely — it does not delete the rows that module already wrote, which is why disabled modules can still leave you with a multi-gigabyte table.
That architecture is the whole diagnostic. Each module owns a different kind of artifact. The 404 Monitor and Redirections own database tables. Sitemap owns a URL plus a cache and a set of rewrite rules. Schema owns output printed during wp_head. Analytics is the awkward one: it owns tables and an external OAuth token and scheduled events, which is exactly why it has the most failure modes and the most search traffic. Once you know which artifact is wrong, you know which module to open.
Two consequences matter operationally. First, several modules write to the database during ordinary front-end requests: the 404 Monitor inserts a row for every 404, bot probes included, and the Link Counter writes on every post save. An install nobody maintains grows tables nobody reads. Second, everything Rank Math prints into a page is subject to your page cache. Fixing schema or a sitemap and then testing against a cached copy is the most common false negative in this plugin, and it produces many bug reports that are not bugs.
Step-by-step
-
Establish which modules are actually on. Everything after this is guesswork without the list.
wp option get rank_math_modules --format=json["link-counter","analytics","seo-analysis","sitemap","rich-snippet","404-monitor","redirections","instant-indexing"]The Schema module is called
rich-snippetinternally — that name confuses people every time. If a slug is absent from this array, that module’s code did not run and cannot be causing your symptom. -
Size what Rank Math has already stored. This one query usually explains a slow admin.
wp db query "SELECT table_name, table_rows, ROUND(data_length/1024/1024) AS mb FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name LIKE '%rank_math%' ORDER BY data_length DESC"Expect a handful of tables.
rank_math_404_logsabove a few hundred thousand rows, orrank_math_internal_linksin the hundreds of megabytes, is the finding — not a curiosity. -
Fix Analytics by walking its four break points in order. The module does not query Google when you load the dashboard. It reads local tables that a scheduled job filled earlier, so an empty screen means the pipeline broke somewhere upstream.
Start with the tables, because a missing table produces exactly the same blank screen as a broken token:
wp db query "SHOW TABLES LIKE '%rank_math_analytics%'"You should see at least
rank_math_analytics_gsc,rank_math_analytics_objectsandrank_math_analytics_inspections, plus a_gatable if you also connected Google Analytics. Nothing at all means a migration copiedwp_postsand friends but skipped the plugin tables — deactivate and reactivate Rank Math to recreate them, then let the fetch repopulate.Next, the scheduled events:
wp cron event list --format=table | grep rank_mathAt least one hook beginning
rank_math/analytics/should appear with a next run in the near future. An empty result means the events were never scheduled; toggling the Analytics module off and on again reschedules them. -
Confirm the scheduler itself runs. A perfectly scheduled event on a site with WP-Cron disabled never fires, and this is the single most common cause of “Analytics not working” on managed hosts.
wp config get DISABLE_WP_CRON wp cron testSuccess: WP-Cron spawning is working as expected.If
DISABLE_WP_CRONistrue, that is correct on a busy site — but only if a system cron replaces it. Check the crontab for a line like the one below, and add it if it is missing.*/5 * * * * cd /home/example/public_html && /usr/local/bin/wp cron event run --due-now --quiet -
Check the property, then force a fetch. Search Console exposes two property types, and Rank Math will happily connect to the wrong one. A domain property (
sc-domain:example.com) covers every subdomain and both schemes; a URL-prefix property (https://example.com/) covers only that exact origin. If the site serveshttps://www.example.com/and you connected the URL-prefix property for the bare domain, the API returns zero rows and the dashboard renders empty with no error. Reconnect under Rank Math’s General Settings, pick the property that matches how your canonical URLs are actually served, then force the job rather than waiting a day:wp cron event run --due-nowExpect the run to report each executed hook. Data appears in the dashboard after the next page load; Search Console itself lags roughly two days, so a fresh connection legitimately shows nothing for recent dates.
-
Bound the 404 Monitor or switch it off. Look before you truncate — the column names are worth knowing:
wp db query "DESCRIBE $(wp db prefix)rank_math_404_logs" wp db query "SELECT uri, COUNT(*) c FROM $(wp db prefix)rank_math_404_logs GROUP BY uri ORDER BY c DESC LIMIT 15"The top rows are almost always bot probes:
/wp-content/plugins/*/readme.txt,/.env,/xmlrpc.php, WordPress paths that never existed on this site. That is noise, not a content problem.The module has two modes. Simple stores the URI and a hit counter. Advanced additionally stores the referer and user agent for every hit, which multiplies the row size and is what turns a large table into an unusable one. If you want the module, run it in Simple mode and add exclusion rules for the probe paths above. If nobody reads the report — the honest answer on most sites — turn the module off and reclaim the space:
wp db query "TRUNCATE TABLE $(wp db prefix)rank_math_404_logs"Real 404 diagnosis belongs in server logs anyway.
-
Force a fresh sitemap, then find the layer that served the old one. Measure first:
curl -s -o /dev/null -w '%{http_code} %{time_total}\n' https://example.com/sitemap_index.xml curl -s https://example.com/sitemap_index.xml | grep -c '<sitemap>'A 200 and a count matching the number of enabled sitemap types. A count of zero with a 200 means something in front of WordPress is returning HTML at that URL.
Rank Math caches generated sitemap XML. Clear the plugin side, rebuild the rewrite rules, then purge the page cache and the CDN in that order:
wp db query "SELECT option_name FROM $(wp db prefix)options WHERE option_name LIKE '%rank_math_sitemap%' LIMIT 10" wp transient delete --all wp rewrite flush --hardIf the first query returns nothing, this version is not caching the sitemap in the options table and the stale copy is coming from your page cache or CDN — which is the more likely culprit regardless. Cloudflare in particular caches
.xmlby extension. -
Kill the duplicate JSON-LD graph. Count the blocks on a public page, not a logged-in one:
curl -s https://example.com/ | grep -c 'application/ld+json'One is correct. Two or more means a second emitter is active: the theme, a second SEO plugin, or a page builder module. Astra, GeneratePress and Kadence all ship their own schema output. Disable the theme’s emitter rather than Rank Math’s — Rank Math produces a single linked
@graphwith shared@idreferences, and a theme’s standaloneOrganizationblock cannot join it. If you would rather keep the theme’s output, removerich-snippetfrom the module list instead. Deciding is the point; leaving both on is the only wrong answer. -
Decide where redirects live before adding more. Rank Math’s Redirections module runs in PHP, after WordPress has bootstrapped and parsed the request:
wp db query "SELECT COUNT(*) FROM $(wp db prefix)rank_math_redirections"Server rules in
.htaccessor an Nginx config fire long before that, so a server rule for the same path always wins and the Rank Math rule never runs — which looks like the plugin ignoring you. Put domain-wide and campaign redirects at the server or the edge, where they cost a fraction as much, and keep the module for the individual URLs your content team manages. A companionrank_math_redirections_cachetable maps matched sources; it rebuilds itself and is safe to truncate. -
Import from Yoast or AIOSEO exactly once, then verify by counting. The importer copies titles, descriptions, focus keywords, canonical URLs, robots meta and social meta. It does not copy Yoast’s indexable table, readability scores, or Yoast’s
%%variable%%template syntax — Rank Math uses single percent signs, so an unconverted title template renders literally. Compare the two sides:wp db query "SELECT COUNT(*) FROM $(wp db prefix)postmeta WHERE meta_key='rank_math_title'" wp db query "SELECT COUNT(*) FROM $(wp db prefix)postmeta WHERE meta_key='_yoast_wpseo_title'"The two counts should be close. A large gap means the import stopped partway, which happens when the batch job exceeds the PHP time limit — rerun it. Deactivate the old plugin but leave its data until you have spot-checked ten posts; the leftover meta is harmless and the rollback is free. Yoast SEO common issues covers what breaks on the other side of that move.
Rank Math sitemap returns 404
A 404 on /sitemap_index.xml means the request never reached Rank Math’s sitemap code. Work through these checks in order, and test with curl after each one so a cached copy cannot fool you.
-
Confirm the Sitemap module is on. The
wp option get rank_math_modulesoutput from step 1 must includesitemap. A disabled module has no route at all. -
Flush the rewrite rules. Rank Math builds the sitemap when it is requested, through a WordPress rewrite rule. In wp-admin, open Settings → Permalinks and click Save Changes without changing anything, or run:
wp rewrite flush --hard -
Compare the query-string URL with the pretty one. If the first URL below returns
200and the second returns404, WordPress is fine and the web server is not passing the pretty URL to it.curl -s -o /dev/null -w '%{http_code}\n' 'https://example.com/?sitemap=1' curl -s -o /dev/null -w '%{http_code}\n' https://example.com/sitemap_index.xml -
On Nginx, add the rewrite rules. Nginx does not read
.htaccess, so the rules WordPress writes there never apply. Rank Math’s documentation gives these lines for the site’sserverblock:rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last; rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; rewrite ^/([a-z]+)?-sitemap\.xsl$ /index.php?xsl=$1 last;Check the configuration with
nginx -t, then reload Nginx. -
Purge the caches last. A page cache or CDN can keep serving a 404 it stored earlier. Purge it and exclude sitemap URLs from caching, as in step 7.
If the 404 started right after a migration or a switch from another SEO plugin, also look for a leftover static file named sitemap_index.xml in the web root, which can conflict with the dynamic sitemap. Rank Math’s sitemap troubleshooting page covers the same checks.
Validate it works
Run all five checks in one pass. Every line should answer for itself:
wp option get rank_math_modules --format=json
wp cron event list --format=table | grep -c rank_math
wp db query "SELECT COUNT(*) FROM $(wp db prefix)rank_math_404_logs"
curl -s https://example.com/ | grep -c 'application/ld+json'
curl -s -o /dev/null -w '%{http_code}\n' https://example.com/sitemap_index.xml
Expected: the module list contains only what you decided to keep; the cron grep returns one or more; the 404 log count is small or the module is off; the JSON-LD count is exactly 1; the sitemap returns 200. Load the Analytics dashboard last — after a forced cron run it should show rows for dates older than two days.
Troubleshooting
Analytics shows some days and gaps on others. The fetch ran late or hit a Google API limit. A system cron every five minutes plus wp cron event run --due-now fills the gap on the next pass. Gaps only for the last two days are normal Search Console lag, not a fault.
The 404 table refills within hours of a truncate. The module is still enabled. Truncating clears history; it does not stop writes. Turn the module off, or add exclusion rules for the probe paths the grouped query surfaced.
The sitemap 404s entirely after a permalink change. The rewrite rules were dropped. Run wp rewrite flush --hard, then check that no real file named sitemap_index.xml exists in the web root — a leftover from a previous plugin shadows the dynamic route, and no amount of flushing helps.
Two Organization nodes survive disabling the theme’s schema. A second SEO plugin is active. Run wp plugin list --status=active and look for Yoast, AIOSEO or SEOPress still installed alongside Rank Math. Two SEO plugins is never a supported configuration.
A redirect loop appears right after importing rules. A self-referencing or circular rule came across in the import. Query the redirections table for rows whose source matches their destination, delete them, then truncate rank_math_redirections_cache.
When this is the wrong approach
If two SEO plugins are active, none of the above applies until one is gone — you will chase symptoms that have two owners. If you need reporting rather than a glance, read Search Console directly instead of the Analytics module: it mirrors a truncated window into your own database and adds real weight for convenience you may not need. Past roughly 100,000 URLs the 404 Monitor and Link Counter are the wrong instruments; server logs answer the same questions without writing rows on every request. And a migration’s redirect map belongs at the edge, not in a PHP table — Rank Math suits the twenty URLs an editor changes each quarter, not fifty thousand. Rank Math’s own knowledge base documents the module settings, and the WP-CLI command reference covers every command used here.
Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.