Blog

XML sitemap returning 404 or with incorrect dates: finding the cause on WordPress

Is your XML sitemap returning a 404, or does it contain duplicate URLs and dates that make no sense? This article helps you find which of the four usual causes affects your site, then fix it permanently rather than re-saving permalinks every week.

XML sitemap returning 404 or with incorrect dates: finding the cause on WordPress

Key points

  • An XML sitemap returning a 404 is most often caused by rewrite rules being rebuilt at the wrong time, not a lost file.
  • If it comes back after saving permalinks and then breaks again, look for the extension that is flushing the rules.
  • Only one sitemap generator per site, and verify the address submitted to Search Console.
  • Lastmod dates that are all identical indicate a bulk operation: fix the source, not the sitemap.

XML sitemap returning 404: what is really happening

An XML sitemap returning a 404 is almost never a lost file. On WordPress, the sitemap does not exist on the disk: it is generated on demand when someone requests its URL. For WordPress to know that this address should produce a sitemap, it needs a rewrite rule. If the rule is missing, WordPress looks for a page with that name, finds none, and returns a 404.

These rules are stored in the database and rebuilt during a “flush”, for example when you save Settings › Permalinks or when a plugin requests it. The issue described in the forums comes from this: a plugin triggers this flush during a request where the SEO plugin has not yet declared its own rules, such as a Heartbeat or AJAX request. The rules are then rebuilt without the sitemap rules.

The symptom is typical: the sitemap comes back when you re-save permalinks, then breaks again a few days later without anyone touching the settings. If you recognize this cycle, the real question is not “how to fix the sitemap”, but “which plugin is flushing the rules at the wrong time”.

  • The sitemap comes back after saving permalinks: likely cause, the rewrite rules.
  • It breaks again for no apparent reason: a plugin triggers a flush on every request or at an inappropriate time.
  • It never comes back: check the server, the cache, or a conflict between two generators instead.

Two sitemap generators on the same site

Since version 5.5, WordPress generates its own sitemap at the address /wp-sitemap.xml. SEO plugins generally disable it to serve their own, under a different name. When two SEO plugins are active, or when an old one left behind settings, the site may end up with two sitemaps, or with an index pointing to sub-sitemaps that no plugin is serving anymore.

Search Console also remembers the address you submitted to it previously. If you changed your SEO plugin, the old address returns a 404 even though the new sitemap is working perfectly. Therefore, check the submitted address before looking any further.

The rule is simple: a single sitemap generator per site. In nexya, the SEO module generates its own sitemap. Since each module is activated from the hub and a disabled module registers nothing, none of its hooks run on the site while it is turned off. You can therefore clearly decide which module produces the sitemap, without hidden double declarations.

A single sitemap generator per site, and the address submitted to Search Console must be the one it serves.

The hub dashboard: each module turns on or off here, and a turned-off module records nothing on the site.
The hub dashboard: each module turns on or off here, and a turned-off module records nothing on the site.

Cache and server holding onto an old response

A sitemap can work in WordPress and still return a 404 for Google. This happens when a page cache or a CDN has cached the error response from the day the rules were missing. Until this copy is cleared, everyone receives the old 404.

The same cache often explains why dates do not change: the displayed sitemap is a copy from several days ago. Clear the plugin cache, the host cache, and the CDN cache, then reload the address in a private window.

On an Nginx server, there is no .htaccess file. Some SEO plugins require specific rules for their .xml addresses, and a server that handles .xml files itself may return a 404 before WordPress is even called. If the sitemap stays at 404 even right after saving permalinks, this is the lead to submit to your web host.

The nexya page cache is part of nexya Pro. It clears the Cloudflare cache on every change. It does not configure the server for you: a missing Nginx rule remains the responsibility of the web host.

Nexya Pro's page cache: to be cleared after a fix so it no longer serves an old 404.
Nexya Pro's page cache: to be cleared after a fix so it no longer serves an old 404.

Duplicate URLs or incorrect URLs

A sitemap that contains the same product twice, or http addresses on an https site, does not come from a display bug. It reflects what the database is telling the generator.

Duplicates often appear after a product import, when two entries have the same content with similar slugs, or when a generator also lists content it shouldn’t. Http addresses usually come from the WordPress Site Address settings or an incomplete migration. Fix the source, not the sitemap: the sitemap will follow on the next display once the cache is cleared.

  • Check Settings › General: WordPress address and site address in https.
  • Look for duplicate entries created by an import, and delete or merge the ones that need to be.
  • Verify that only one generator is active, to avoid mixing two lists.

Meaningless lastmod dates

The lastmod date of a URL generally reflects the date the content was last modified. If all your pages display the same date, it means an operation affected them all: an import, a bulk edit, an update that re-saves contents, or a plugin that writes to every post.

Google states that it only takes lastmod into account if these dates are consistently reliable over time. Dates that change all at once without any real content change mainly teach it to stop trusting them. Therefore, identify the operation that affected all the content and avoid repeating it on the live site.

An activity log helps here: it shows who modified what and when. Nexya’s log is a free module, separate from the SEO module.

Putting the sitemap back in order, step by step

  1. 1

    Keep a single sitemap generator

    Deactivate the sitemap of any SEO extensions you no longer use. If you choose nexya, turn on the SEO module from the hub's module list: it will then generate its own sitemap.

    Keep a single sitemap generator
  2. 2

    Rebuild rules and clear caches

    Go to Settings › Permalinks and save without making any changes, then clear your page cache, host cache, and CDN cache. With nexya Pro's page cache, the Cloudflare cache is cleared with every modification.

    Rebuild rules and clear caches
  3. 3

    Verify the address and submit it

    Open the sitemap in an incognito window, check the URLs and dates, then submit this address in Search Console while removing the old one. The SEO module will then notify engines of new content using IndexNow.

    Verify the address and submit it

What nexya does, and what it doesn’t do

Nexya’s free SEO module generates its own sitemap. It also notifies search engines of new content using IndexNow, without waiting for them to recrawl the sitemap.

It does not replace a missing server configuration, does not fix duplicate product pages on your store, and does not prevent another extension from flushing rewrite rules at the wrong time. If a third-party extension causes these flushes, you must find and disable or fix it, regardless of the sitemap generator used.

What it provides is a clean starting point: a single generator that you turn on or off from the hub, and engines alerted to new content.

FAQ

Why does my sitemap come back after saving permalinks, and then break again?

Saving rebuilds the rewrite rules, including the sitemap. If the sitemap breaks again, an extension is triggering this rebuild during a request where the sitemap rules are not declared, such as a Heartbeat or AJAX request.

Can I keep the WordPress sitemap and an SEO plugin's sitemap?

It is better to use a single generator. Two sitemaps result in two sometimes contradictory lists, and Search Console may keep an address that no longer works.

Is nexya's SEO module paid?

No. The SEO module, along with its sitemap and IndexNow, is part of the free version. Page caching, however, is part of nexya Pro.

Does nexya fix a missing Nginx rule?

No. Server configuration remains the host's responsibility. If the sitemap stays 404 right after saving permalinks, ask them about it.

The modules in this post

nexya seo nexya hub nexya cache

Try nexya Pro free for 7 days

Every module, forms, newsletters and the page cache, on your site. No commitment.

See the plans Or discover the free version