Skip to content
WordPress Support

WordPress Sitemap Not Working? Check the Address

Many sitemap 404s come from checking the wrong address. Here is where your sitemap should be, and what each kind of failure means.

A laptop with code open on a white desk
8 sections · 7 min read
In this article · 8 sections

Google Search Console says it “couldn’t fetch” your sitemap. Or you typed yoursite.com/sitemap.xml into a browser to check, and got a 404 page. Or the sitemap opens, but half your pages are not in it, or it is full of a page of jumbled text and an error about an XML declaration.

A WordPress sitemap not working is usually less serious than it sounds, and the very first thing to check is whether you are even looking at the right address. WordPress can produce a sitemap on its own, SEO plugins can produce their own instead, and each lives at a different address. Quite often, a sitemap xml 404 simply means someone is checking an address that was never supposed to exist.

Which address is your sitemap supposed to be at?

Work out which system produces your sitemap before testing anything.

What produces it Usual address
WordPress itself, with no SEO plugin /wp-sitemap.xml
Yoast SEO /sitemap_index.xml
Rank Math /sitemap_index.xml
Other SEO or sitemap plugins Shown in that plugin’s settings, often /sitemap.xml

WordPress has included its own basic sitemap since version 5.5. When an SEO plugin that makes sitemaps is active, the plugin normally switches the built-in one off and serves its own. So on a site running Yoast, /wp-sitemap.xml may redirect or fail, and that is expected. On a site with no SEO plugin, /sitemap_index.xml returning 404 is equally normal.

Your SEO plugin’s settings page will usually show a link to the live sitemap. Use that link, not a guess, and check that the same address is the one submitted in Search Console. An old submission pointing at an address from a previous plugin is a common source of “couldn’t fetch”.

What you see when you open it, and what each result means

Once you know the address, open it in a private browser window and match the result. Most cases of a WordPress sitemap not working fall into one of these five outcomes.

A 404 page

  1. Check Settings, then Reading. If “Discourage search engines from indexing this site” is ticked, WordPress turns its built-in sitemap off. That setting is often left on by accident after a site launches from a staging copy, and it has much bigger consequences than the sitemap, so fix it straight away if the site is meant to be public.
  2. Re-save permalinks. A sitemap address only works if WordPress knows how to route it, and that routing list can go stale. Open the Permalinks screen under Settings and press the save button, leaving the options as they are. That one action refreshes the routing and clears many sitemap 404s by itself. If all your inner pages are also returning 404, the problem is wider; our guide to pages that 404 while the homepage works covers that.
  3. Check the plugin’s sitemap switch. SEO plugins let you turn sitemaps off. Make sure the feature is on. Turning it off, saving, then turning it back on and saving again is a common way to make the plugin rebuild its addresses.
  4. Nginx servers. Some plugins’ sitemap addresses need rules in the Nginx configuration, which WordPress cannot write itself. Yoast and others document the rules required. On managed hosting, ask the host to check them.

A sitemap that is old or from a different plugin

If the sitemap opens but lists pages you deleted long ago, or looks nothing like your current SEO plugin’s output, check the site’s main folder for a real file called sitemap.xml. Older sitemap generator plugins wrote physical files. A server delivers a real file before WordPress ever sees the request, so a forgotten file from years ago can sit in front of your current sitemap. Download it as a copy, then remove it, and test again.

Cache layers can do something similar. A CDN or server cache may keep serving an old sitemap. Purge them and check again.

An XML error instead of a list

Browsers show an error such as “XML declaration allowed only at the start of the document” or “error on line 1” when something has printed text before the sitemap begins. Usually that text is invisible: a blank line or space at the start or end of a PHP file in the theme or a plugin. A sitemap has to start with its XML declaration and nothing else, so even one stray character breaks it.

To find it, right-click and view the page source. If the first line is empty, or there is visible text before the XML begins, something is adding output. The usual suspects are the theme’s functions.php file, a recently edited plugin, or a snippet added to the site. The same stray output often causes PHP warnings elsewhere; the explanation in the “cannot modify header information” error follows the same thread and shows how to trace the file.

A styled table instead of raw code

That is not a fault. WordPress and most SEO plugins attach a stylesheet that makes the sitemap readable for people. Search engines read the code underneath.

A sitemap missing some content

  • Pages or posts set to noindex in your SEO plugin are normally left out of the sitemap on purpose.
  • Whole content types or taxonomies can be excluded in the plugin’s settings. Check whether products, categories or portfolio items are switched off.
  • Drafts, private and password-protected posts are not included.
  • Large sites are split into several smaller sitemaps listed in an index. Open the index and click through to the sub-sitemaps before deciding something is missing.

Reading the Search Console side

Search Console reports sitemap problems in its own words, and they do not always mean the sitemap is broken.

  • “Couldn’t fetch”. Google could not retrieve the file at that moment. Confirm the address opens in a private window. If it does, a firewall or security plugin may be blocking Google’s crawler, or the status may simply not have updated yet; recheck after a few days before changing anything.
  • “Sitemap is HTML”. The address returned a web page instead of XML. That often means a redirect to the home page or a 404 page served with a normal status code.
  • Submitted pages not indexed. This is not a sitemap fault. A sitemap tells Google pages exist; it does not make Google index them.

Google’s own overview of sitemaps explains what a sitemap does and does not do, which is useful context before you spend hours on one.

Two plugins, two sitemaps

A site that has had several SEO plugins over the years can end up with more than one active at the same time. It happens after a trial of a new plugin that never got finished, or when a site is handed over with both installed. Each may try to produce a sitemap, switch the built-in one off, and claim the same addresses. The result can be a sitemap that works one day and not the next, depending on which plugin’s rules were loaded last.

Look through the Plugins screen for anything with SEO or sitemap in its name or description. Keep one. Deactivating the other is safe in itself, but check first that its settings, such as titles and descriptions for your pages, have been moved to the one you are keeping, or you may lose them from search results.

After the fix: tell Search Console

Once the sitemap opens correctly in a private window, go to the Sitemaps report in Search Console. Remove any old addresses you no longer use, submit the working one if it is not already listed, and leave it. Google fetches sitemaps on its own schedule, so the status may not change straight away. Check back in a few days rather than resubmitting it every hour.

It is also worth spot-checking a few addresses from inside the sitemap. Click three or four of them. If any redirect, return 404 or open a page you meant to hide, the sitemap is advertising pages it should not, and that is worth cleaning up in the SEO plugin’s settings.

Check robots.txt points to the right place

When the built-in sitemap is active, WordPress adds a line pointing to it in the virtual robots.txt it generates. If your site has a real robots.txt file in its main folder, WordPress’s version is never shown, and the file may point to an old sitemap address or none. Open yoursite.com/robots.txt and look for a “Sitemap:” line. If it names an address that no longer works, update it. Our free robots.txt generator can help you write a clean file.

When the sitemap is fine but older posts still are not found

A working sitemap is only one route by which search engines find pages. If your blog’s page 2 and beyond are broken, older posts lose their internal links even with a perfect sitemap. That side is covered in the guide to fixing blog pagination that returns 404.

WordPress sitemap not working after all that? Notes to keep

  • The sitemap address you expect, and which plugin is meant to produce it
  • What appears when you open it in a private window: 404, error text, old content or a working list
  • The exact status shown in Search Console
  • Whether a physical sitemap.xml or robots.txt exists in the site’s main folder

If the cause is stray output buried in theme code, or server rules you cannot reach, that is where wordpress bug fixing experts can save you the hunt.

Most broken sitemaps are fixed by one of three things: checking the right address, re-saving permalinks, or removing a forgotten file. Try those before anything else, and leave the deeper work for when they have not helped.

Next in this series: jQuery Is Not Defined in WordPress: Find the Cause

Is Your Website Working Properly?

Get a free website health check from WebMaintor. We'll review your website's speed, security, forms, and technical health — and tell you exactly what needs attention.

No obligation. No automated reports. A real review by our team.