A bulk HTTP status checker is one of the most useful technical SEO tools you can build yourself. After a site migration, a URL structure change or a big content cleanup, you need to know which old URLs now return 404, which redirect through three hops instead of one, which use a temporary 302 that should be permanent, and whether your XML sitemap still lists URLs that redirect. Online checkers limit how many URLs you can paste, and crawlers do far more than you need. This guide builds a small, dependency-free Python script that reads a URL list or a sitemap, follows every redirect hop itself, flags the problems that matter for search engines and writes a CSV report. It was tested against a local server that serves every kind of problem on purpose.

bulk HTTP status checker in Python: load URLs from a sitemap, request each one without following redirects, record every hop, flag errors, chains and loops, then export a CSV report
A bulk HTTP status checker: load URLs, request each without auto-redirects, follow and record every hop, flag problems and write a CSV report.

From my own work: After migrations I always run a status check of the old URL list and the new sitemap before telling a client the move is done. The issues it finds are rarely dramatic, usually a few chains created by an older redirect plugin and some 302s, but they are much cheaper to fix in the first week than after Google has recrawled everything.

What a bulk HTTP status checker should report

A status code alone is not enough. For each URL, an SEO-focused checker should record the full redirect path and judge it. These are the checks the script below performs, and why each matters:

Check Example Why it matters
Final status 4xx 404, 410 Broken pages lose their links and traffic; fix or redirect intentionally
Final status 5xx 500, 503 Server errors slow crawling and can drop pages if they persist
Redirect chain 301 to 302 to 301 to 200 Every hop adds latency and risk; point the first URL straight at the final one
Redirect loop A to B to A The page can never load for users or crawlers
Temporary redirect 302, 303, 307 in the path Signals the move is not permanent; use 301 or 308 for permanent moves
https to http https://site/a redirects to http://site/a A security downgrade and usually a configuration mistake
Redirecting URL in sitemap Sitemap lists /old, which redirects Sitemaps should list final canonical URLs only

Google treats permanent and temporary redirects differently: a permanent redirect is a strong signal that the target should be shown in search results, while a temporary one suggests keeping the source (Google: redirects and Google Search). Google’s crawlers follow up to 10 redirect hops by default (Google: HTTP status codes), but each extra hop still wastes crawl time and slows real users, so the goal is one hop at most.

The Python script: standard library only

The key design decision is to disable automatic redirects. Python’s urllib.request follows redirects through HTTPRedirectHandler; overriding its redirect_request() method to return None makes every 3xx response come back to our code as an HTTPError with its Location header, so we can record each hop (Python docs: HTTPRedirectHandler). Save this as url_status.py; it runs on Python 3.9 and newer:

#!/usr/bin/env python3
"""url_status.py - bulk HTTP status and redirect chain checker (standard library only).

Usage:
  python3 url_status.py urls.txt            > report.csv
  python3 url_status.py https://example.com/sitemap.xml > report.csv
"""
import csv
import gzip
import sys
import urllib.error
import urllib.parse
import urllib.request
import xml.etree.ElementTree as ET
from concurrent.futures import ThreadPoolExecutor

UA = "Mozilla/5.0 (compatible; url-status-checker/1.0)"
TIMEOUT = 15
MAX_HOPS = 10
WORKERS = 8

class NoRedirect(urllib.request.HTTPRedirectHandler):
    """Return 3xx responses to us instead of following them."""
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        return None

OPENER = urllib.request.build_opener(NoRedirect)

def request(url, method):
    req = urllib.request.Request(url, method=method, headers={"User-Agent": UA})
    try:
        with OPENER.open(req, timeout=TIMEOUT) as r:
            return r.status, r.headers
    except urllib.error.HTTPError as e:      # 3xx (because we do not follow), 4xx, 5xx
        return e.code, e.headers

def fetch_status(url):
    """HEAD first; fall back to GET when the server rejects or mishandles HEAD."""
    status, headers = request(url, "HEAD")
    if status in (403, 405, 501):
        status, headers = request(url, "GET")
    return status, headers

def check(url):
    hops, seen, current = [], set(), url
    try:
        for _ in range(MAX_HOPS + 1):
            if current in seen:
                return row(url, hops, "redirect loop")
            seen.add(current)
            status, headers = fetch_status(current)
            hops.append((status, current))
            if status in (301, 302, 303, 307, 308) and headers.get("Location"):
                current = urllib.parse.urljoin(current, headers["Location"])
                continue
            return row(url, hops, "")
        return row(url, hops, f"more than {MAX_HOPS} redirects")
    except Exception as e:                    # DNS, TLS, timeout, connection refused
        return row(url, hops, f"{type(e).__name__}: {e}")

def row(url, hops, error):
    final_status, final_url = hops[-1] if hops else ("", "")
    redirects = len(hops) - 1 if hops else 0
    issues = []
    if error:
        issues.append(error)
    if isinstance(final_status, int) and final_status >= 400:
        issues.append(f"final status {final_status}")
    if redirects > 1:
        issues.append(f"redirect chain ({redirects} hops)")
    if any(s in (302, 303, 307) for s, _ in hops[:-1]):
        issues.append("temporary redirect")
    if url.startswith("https://") and final_url.startswith("http://"):
        issues.append("redirects to http")
    return {
        "url": url,
        "first_status": hops[0][0] if hops else "",
        "final_status": final_status,
        "final_url": final_url,
        "redirects": redirects,
        "chain": " -> ".join(f"{s} {u}" for s, u in hops),
        "issues": "; ".join(issues),
    }

def read_sitemap(url, depth=0):
    req = urllib.request.Request(url, headers={"User-Agent": UA})
    with urllib.request.urlopen(req, timeout=TIMEOUT) as r:
        data = r.read()
    if data[:2] == b"x1fx8b":                # sitemap.xml.gz
        data = gzip.decompress(data)
    root = ET.fromstring(data)
    ns = "{http://www.sitemaps.org/schemas/sitemap/0.9}"
    if root.tag == ns + "sitemapindex" and depth < 2:
        out = []
        for loc in root.iter(ns + "loc"):
            out += read_sitemap(loc.text.strip(), depth + 1)
        return out
    return [loc.text.strip() for loc in root.iter(ns + "loc")]

def load_urls(source):
    if source.startswith(("http://", "https://")):
        return read_sitemap(source)
    with open(source, encoding="utf-8") as f:
        return [line.strip() for line in f if line.strip() and not line.startswith("#")]

if __name__ == "__main__":
    urls = list(dict.fromkeys(load_urls(sys.argv[1])))   # de-duplicate, keep order
    with ThreadPoolExecutor(max_workers=WORKERS) as pool:
        results = list(pool.map(check, urls))
    if sys.argv[1].startswith(("http://", "https://")):    # a sitemap should list final URLs only
        for r in results:
            if r["redirects"]:
                r["issues"] = "; ".join(filter(None, [r["issues"], "redirecting URL in sitemap"]))
    writer = csv.DictWriter(sys.stdout, fieldnames=list(results[0]))
    writer.writeheader()
    writer.writerows(results)
    bad = sum(1 for r in results if r["issues"])
    print(f"{len(results)} URLs checked, {bad} with issues", file=sys.stderr)
    sys.exit(1 if bad else 0)

How the main parts work:

  • NoRedirect stops urllib from following redirects, so check() sees each 3xx and resolves relative Location values with urljoin. RFC 9110 allows a relative reference in Location, which is why the join is needed (RFC 9110: Location).
  • fetch_status() sends HEAD first because it skips the body, then retries with GET when a server answers 403, 405 or 501. Some servers and firewalls handle HEAD badly, and you want the status a browser would get.
  • Loop detection uses a set of URLs already seen in this chain, and the MAX_HOPS limit stops runaway chains.
  • read_sitemap() handles plain and gzip-compressed sitemaps and follows sitemap index files two levels deep.
  • ThreadPoolExecutor checks eight URLs at a time. Network checks spend most of their time waiting, so threads give a large speedup without any extra package.
  • The exit code is 1 when any URL has an issue, which lets a CI job fail after a deploy.

Test it against a local server with known problems

Before pointing a checker at a client site, prove that it detects each problem. This test server has a working page, a single redirect, a three-hop chain with a 302 in the middle, a loop, 404, 410 and 500 responses, a page that rejects HEAD, and a sitemap listing all of them:

# testserver.py - local site with every kind of problem the checker should catch
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer

ROUTES = {
    "/ok": (200, None),
    "/old": (301, "/ok"),
    "/chain-1": (301, "/chain-2"),
    "/chain-2": (302, "/chain-3"),
    "/chain-3": (301, "/ok"),
    "/loop-a": (301, "/loop-b"),
    "/loop-b": (301, "/loop-a"),
    "/gone": (410, None),
    "/error": (500, None),
}
SITEMAP = """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
""" + "".join(f"<url><loc>http://127.0.0.1:8098{p}</loc></url>n" for p in list(ROUTES) + ["/no-head", "/missing"]) + "</urlset>"

class H(BaseHTTPRequestHandler):
    def respond(self, body=True):
        if self.path == "/sitemap.xml":
            data = SITEMAP.encode()
            self.send_response(200); self.send_header("Content-Type", "application/xml")
            self.send_header("Content-Length", str(len(data))); self.end_headers()
            if body: self.wfile.write(data)
            return
        if self.path == "/no-head" and self.command == "HEAD":
            self.send_response(405); self.end_headers(); return
        code, loc = ROUTES.get(self.path, (404, None))
        if self.path == "/no-head": code = 200
        self.send_response(code)
        if loc: self.send_header("Location", loc)
        self.send_header("Content-Length", "0"); self.end_headers()
    def do_GET(self): self.respond()
    def do_HEAD(self): self.respond(body=False)
    def log_message(self, *a): pass

ThreadingHTTPServer(("127.0.0.1", 8098), H).serve_forever()
python3 testserver.py &
python3 url_status.py http://127.0.0.1:8098/sitemap.xml > report.csv
# 11 URLs checked, 9 with issues
cut -d, -f1,7- report.csv
url,issues
http://127.0.0.1:8098/ok,
http://127.0.0.1:8098/old,redirecting URL in sitemap
http://127.0.0.1:8098/chain-1,redirect chain (3 hops); temporary redirect; redirecting URL in sitemap
http://127.0.0.1:8098/chain-2,redirect chain (2 hops); temporary redirect; redirecting URL in sitemap
http://127.0.0.1:8098/chain-3,redirecting URL in sitemap
http://127.0.0.1:8098/loop-a,redirect loop; redirecting URL in sitemap
http://127.0.0.1:8098/loop-b,redirect loop; redirecting URL in sitemap
http://127.0.0.1:8098/gone,final status 410
http://127.0.0.1:8098/error,final status 500
http://127.0.0.1:8098/no-head,
http://127.0.0.1:8098/missing,final status 404

Every planted problem is reported, the page that refuses HEAD passes thanks to the GET fallback, and the full chain column in the CSV shows each hop, for example 301 /chain-1 -> 302 /chain-2 -> 301 /chain-3 -> 200 /ok. A connection failure is reported in the issues column rather than crashing the run, such as URLError: <urlopen error [Errno 61] Connection refused> on macOS.

Run it on a real site

Use a plain text file with one URL per line for old URLs after a migration, or pass the sitemap URL directly:

# old URLs exported from analytics, Search Console or the old sitemap
python3 url_status.py old-urls.txt > migration-check.csv

# the live sitemap or sitemap index
python3 url_status.py https://example.com/sitemap_index.xml > sitemap-check.csv

Be polite to the server you are checking. Eight parallel workers are fine for your own site on reasonable hosting; reduce WORKERS for small shared hosting or sites behind strict rate limits, and whitelist your IP in the firewall if a WAF starts answering with 403 or 429. A 429 in the report means you were rate limited, not that the page is broken.

How to fix what the checker finds

  • Chains: update the first redirect so it points straight at the final URL. On Nginx that means editing the old rule’s target; in WordPress redirect plugins, edit the source rule rather than adding another. Collapsing chains is one of the steps in the website migration SEO checklist.
  • Temporary redirects: change 302 or 307 to 301 or 308 when the move is permanent. The server configurations for Nginx, Apache and WordPress are in 301 redirects for SEO.
  • Loops: usually two rules fighting, such as an http-to-https rule and a www rule, or a plugin and the server both forcing a trailing slash. Test with curl -sIL after each change.
  • 404s: redirect to the closest equivalent page if one exists, otherwise let it return 404 or 410. Do not redirect every missing page to the home page.
  • Redirecting sitemap URLs: regenerate the sitemap so it lists only final URLs. The rules for a clean sitemap are in XML sitemap best practices.
  • 5xx errors: check server logs at the time of the check; intermittent 500s or 503s often point to PHP-FPM or database limits rather than to the page itself.

Google’s sitemap guidelines say to include the URLs you want shown in search results, meaning canonical URLs, and a single sitemap is limited to 50,000 URLs or 50 MB uncompressed (Google: build and submit a sitemap). Pages that redirect or return errors in a sitemap send mixed signals, and they often show up later as indexing problems, as discussed in fixing Crawled – currently not indexed.

Run the check automatically after deploys

Because the script exits with status 1 when it finds issues, it slots straight into CI. This GitHub Actions job checks the live sitemap every Monday and after each manual trigger:

# .github/workflows/url-status.yml
name: URL status check
on:
  schedule:
    - cron: "0 6 * * 1"
  workflow_dispatch:
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: python3 url_status.py https://example.com/sitemap_index.xml > report.csv
      - if: always()
        uses: actions/upload-artifact@v4
        with:
          name: url-status-report
          path: report.csv

The if: always() line uploads the CSV even when the check fails.

Limits of a status checker

  • It does not render JavaScript. Client-side redirects and pages that show an error message with a 200 status (soft 404s) need a browser-based tool or a content check.
  • It does not crawl. It checks the URLs you give it. To find broken internal links, extract links from your pages first, then feed them to the checker.
  • Results depend on where you run it. Geo-redirects, bot protection and CDN rules can answer differently for a data-centre IP than for a visitor or for Googlebot. Confirm odd results with the URL Inspection tool in Search Console.

Bulk HTTP status checker checklist

  • Redirects followed one hop at a time, with every hop recorded.
  • Final 4xx and 5xx flagged; 429 treated as rate limiting.
  • Chains longer than one hop, loops and more than 10 hops flagged.
  • 302, 303 and 307 in the path flagged for review.
  • https to http downgrades flagged.
  • Sitemap URLs that redirect flagged; sitemap index and gzip supported.
  • HEAD with GET fallback; sensible timeout and worker count.
  • CSV output and a non-zero exit code for CI.

Want this done on your own server or site?

I am Saizul Amin, a web developer and technical SEO consultant. I set up and harden VPS servers, migrate WordPress sites, fix indexing problems and build automations. See my portfolio or get in touch.

FAQ

What is a bulk HTTP status checker?

It is a tool that requests a list of URLs and reports the HTTP status code of each one, usually including the redirect path. SEO teams use it after migrations and redesigns to find broken pages, redirect chains, loops and temporary redirects before search engines do.

How can I check HTTP status codes for many URLs in Python?

Use urllib.request from the standard library or the requests package, disable automatic redirects so you can record each hop, and run the checks in a ThreadPoolExecutor. The script in this guide does that and writes the results to a CSV file.

How many redirects will Googlebot follow?

Google documents that its crawlers follow up to 10 redirect hops by default, although some Google tools follow fewer. Even so, keep redirects to a single hop, because every extra hop slows users and wastes crawl time.

Should a sitemap contain URLs that redirect?

No. A sitemap should list the canonical URLs you want indexed, each returning 200. If a URL in the sitemap redirects, replace it with the final destination URL and regenerate the sitemap.

Why use HEAD requests and when do they fail?

HEAD returns only headers, so checks are faster and use less bandwidth. Some servers, firewalls and applications reject HEAD with 403, 405 or 501 or answer it differently from GET, so a good checker falls back to GET in those cases.

Sources

NEW BLOGS. REAL STRATEGIES. REAL RESULTS.

Join our community and receive powerful SEO tips, web optimization guides, and growth strategies as soon as they’re published.

Don’t just read blogs — stay ahead of the competition.

We don’t spam! Read our privacy policy for more info.

Share.

Comments are closed.