How to check every URL in a sitemap for errors

A sitemap should list only live, final URLs. Here is how to test every entry and what to do with the ones that fail.

1. A shell loop (small sitemaps)

curl -s --compressed https://www.sitemaps.org/sitemap.xml | grep -oE '<loc>[^<]+</loc>' | sed -E 's#</?loc>##g' |
while read -r url; do
  echo "$(curl -s -o /dev/null -w '%{http_code}' "$url") $url"
  sleep 0.5
done

Each line shows the HTTP status and the URL. Add | grep -v '^200' to see only problems. --compressed handles servers that send the file gzip-encoded. If the file is a sitemap index (its <loc> entries point to more sitemaps), run the loop on each child sitemap; a .xml.gz file needs | gunzip after curl.

2. What to do with each status

3. Large sitemaps

A sitemap can hold up to 50,000 URLs, and an index can point to many of them. At one request every half second, 50,000 URLs take about 7 hours. Run the checks in parallel, but gently, and watch for rate limiting.

Our Sitemap URL Status Checker on Apify reads sitemaps and sitemap indexes (gzip included), checks every URL and returns one row per URL with status and redirect target, as CSV, Excel or JSON. To build a new sitemap from a URL list, use the free sitemap generator.

Frequently asked questions

Why does Google Search Console report sitemap URLs as errors?

Usually because entries redirect, return 404, are blocked by robots.txt or carry noindex. Fix the sitemap so it lists only final, indexable URLs.

Should redirected URLs stay in the sitemap?

No. List the final URL the redirect points to.

Where is my sitemap?

Check https://your-site.com/robots.txt for a 'Sitemap:' line, or try /sitemap.xml and /sitemap_index.xml.

Written with AI assistance. The shell loop was run against sitemaps.org's own sitemap on 2026-10-01. The Apify tool is ours; the APIs are free to call directly.