# Broken Link & Redirect Checker (Site Crawl or Sitemap) (`beryline_pastel/broken-link-redirect-checker`) Actor

Crawl a website or sitemap.xml to find broken links (4xx/5xx), redirect chains, redirect loops, and insecure HTTP links on HTTPS pages. Respects robots.txt and lists every page where each broken link appears.

- **URL**: https://apify.com/beryline_pastel/broken-link-redirect-checker.md
- **Developed by:** [Beryline Pastel](https://apify.com/beryline_pastel) (community)
- **Categories:** SEO tools, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 page crawleds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Broken Link & Redirect Checker (Site Crawl or Sitemap)

Find **broken links, redirect chains, redirect loops and insecure http links** on any website. Give it a start URL and/or a **sitemap.xml**; it crawls your pages with plain HTTP (no headless browser, so it is fast and cheap) and checks every link, image, stylesheet, script and canonical tag exactly once. Results are one clean row per problem link, with the list of pages where it appears, ready to export to CSV, Excel, JSON or Google Sheets.

### What it finds

| Problem | Meaning |
|---|---|
| `broken` | 4xx / 5xx response, DNS failure, connection error or timeout |
| `redirect-chain` | 2 or more redirect hops before the final page |
| `redirect-loop` | Redirects that never end |
| `http-on-https-page` | An `http://` link, image or script used on an `https://` page |
| `redirect` | A single 301/302/307/308 redirect on an **internal** link (update the link to the final URL) |

Checked: `<a href>`, `<img src>`, `<link rel="stylesheet">`, `<link rel="canonical">`, `<script src>`. Skipped: `mailto:`, `tel:`, `javascript:`, `data:` and `#fragments`.

### Why use it

- **Whole-site check from a sitemap or a start page.** Same-host breadth-first crawl, up to your page limit.
- **Every unique link is checked once**, no matter how many pages contain it. `foundOn` lists up to 20 pages, `foundOnCount` gives the total, so you know which broken link to fix first.
- **Full redirect chain** for each redirecting link, with status code per hop and the final URL.
- **Polite by design:** honors `robots.txt` (`Disallow` / `Allow` / `Crawl-delay` for `User-agent: *` or this tool's own name), max 4 parallel requests per host, small delay between requests, honors `429 Retry-After`. Identifies itself with a configurable User-Agent.
- **You only pay for pages actually fetched.** Pages that fail are free, and links checked are never charged.

### Input

| Field | Description |
|---|---|
| `startUrls` | Pages where the crawl starts (same host only) |
| `sitemapUrl` | Optional sitemap or sitemap index; its pages are checked and crawled |
| `maxPages` | Max HTML pages fetched per run (default 50) |
| `checkExternalLinks` | Also check links to other sites (default true; external pages are never crawled) |
| `maxLinksPerPage` | Process only the first N unique links per page (default 300) |
| `respectRobotsTxt` | Skip pages disallowed in robots.txt (default true) |
| `concurrency` | Total parallel requests (default 8; per host never above 4) |
| `requestTimeoutSecs` | Per-request timeout (default 15) |
| `userAgent` | User-Agent sent with every request |

```json
{ "startUrls": ["https://example.com/"], "sitemapUrl": "https://example.com/sitemap.xml", "maxPages": 200, "checkExternalLinks": true }
```

### Output (one row per problem link)

```json
{
  "url": "https://example.com/old-page",
  "status": 200,
  "problem": "redirect-chain",
  "redirectChain": [
    { "url": "https://example.com/old-page", "status": 301 },
    { "url": "https://example.com/old-page/", "status": 302 }
  ],
  "finalUrl": "https://example.com/new-page",
  "foundOn": ["https://example.com/", "https://example.com/blog/"],
  "foundOnCount": 2,
  "linkType": "a",
  "linkTypes": ["a"],
  "isExternal": false
}
```

Broken links without a response carry `status: null` and an `error` such as `dns: fetch failed` or `timeout: ...`. If a start URL itself cannot be fetched you get a row with `status: "error"`.

A summary is saved to the key-value store as `SUMMARY`:

```json
{ "pagesCrawled": 40, "linksChecked": 280, "brokenCount": 15, "redirectCount": 16, "problemLinks": 34,
  "byProblem": { "broken": 15, "redirect-loop": 2, "redirect-chain": 5, "http-on-https-page": 3, "redirect": 9 }, "skippedByRobots": 21 }
```

`redirectCount` = redirect, redirect-chain and redirect-loop rows. `linksChecked` = unique links checked.

### Pricing

Pay per event: **$0.005 per page crawled** (one successfully fetched HTML page). 1,000 pages = $5, and that includes checking every link found on them. Failed pages are free. Set *Max cost per run* to cap spending; the actor stops crawling cleanly when the limit is reached and still reports the links it already found.

### FAQ

**Does it run JavaScript?** No. It reads the HTML the server returns, so links added only by JavaScript are not seen. This keeps runs fast and cheap.

**How long does it take?** Roughly 10-15 links per second per site because of the polite per-host limits. A 30-page site with about 850 unique links takes a few minutes.

**Why was a page skipped?** Pages disallowed by robots.txt are neither crawled nor checked (counted in `skippedByRobots`). Turn off *Respect robots.txt* only for sites you own.

**Why does a link work in my browser but show 403/429 here?** Some sites (social networks, large retailers) block automated requests. Treat 403/429/999 on external links as "verify manually".

**Does a link with a single redirect count as a problem?** Only internal links (it is a cleanup recommendation). External single redirects are ignored. `http://` links on `https://` pages are always reported.

### Limits

Same-host crawling only; no login, no forms, no JavaScript rendering; PDFs/images are checked but not parsed; at most 10 redirect hops are followed; HTML above about 3 MB is truncated.

### Use with AI agents (MCP)

This Actor works as a tool for Claude, ChatGPT, Cursor and other MCP clients through the Apify MCP server:

```
https://mcp.apify.com?tools=beryline_pastel/broken-link-redirect-checker
```

Example prompt: *"Crawl https://example.com and list all broken links and redirect chains."*

### Related tools by the same author

- [Bulk Core Web Vitals Auditor](https://apify.com/beryline_pastel/bulk-core-web-vitals-auditor)
- [Bulk Domain Checker (expiry, WHOIS, DNS, SSL)](https://apify.com/beryline_pastel/bulk-domain-checker)
- [Bulk Phone Number Validator (E.164)](https://apify.com/beryline_pastel/bulk-phone-number-validator)
- [Bulk PDF Text Extractor](https://apify.com/beryline_pastel/bulk-pdf-text-extractor)
- [Bulk Email Validator (MX, disposable, typos)](https://apify.com/beryline_pastel/bulk-email-validator-mx-disposable)

# Actor input Schema

## `startUrls` (type: `array`):

Pages where the crawl starts. Only pages on the same host are crawled. Bare domains are fine (https:// is added).

## `sitemapUrl` (type: `string`):

A sitemap.xml or sitemap index. Its pages are checked and crawled too (up to Max pages).

## `maxPages` (type: `integer`):

Upper limit of HTML pages fetched per run. Each successfully fetched page is one billable event.

## `checkExternalLinks` (type: `boolean`):

Also check links that point to other websites (HEAD requests only, never crawled).

## `maxLinksPerPage` (type: `integer`):

Only the first N unique links of each page are processed. Protects against huge link lists.

## `respectRobotsTxt` (type: `boolean`):

Skip pages disallowed for User-agent \* (or this tool's own name) in robots.txt. Crawl-delay is honored up to 5 seconds.

## `concurrency` (type: `integer`):

Total parallel requests. A separate cap of 4 requests per host always applies.

## `requestTimeoutSecs` (type: `integer`):

Per request timeout. Links that time out are reported as broken.

## `userAgent` (type: `string`):

Sent with every request so site owners can identify the checker. Robots.txt rules for this name are honored in addition to \*.

## Actor input object example

```json
{
  "startUrls": [
    "https://crawler-test.com/"
  ],
  "maxPages": 5,
  "checkExternalLinks": true,
  "maxLinksPerPage": 60,
  "respectRobotsTxt": true,
  "concurrency": 8,
  "requestTimeoutSecs": 15,
  "userAgent": "BrokenLinkChecker/1.0 (+https://apify.com; link checker bot)"
}
```

# Actor output Schema

## `problems` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        "https://crawler-test.com/"
    ],
    "maxPages": 5,
    "maxLinksPerPage": 60
};

// Run the Actor and wait for it to finish
const run = await client.actor("beryline_pastel/broken-link-redirect-checker").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "startUrls": ["https://crawler-test.com/"],
    "maxPages": 5,
    "maxLinksPerPage": 60,
}

# Run the Actor and wait for it to finish
run = client.actor("beryline_pastel/broken-link-redirect-checker").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    "https://crawler-test.com/"
  ],
  "maxPages": 5,
  "maxLinksPerPage": 60
}' |
apify call beryline_pastel/broken-link-redirect-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,beryline_pastel/broken-link-redirect-checker"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/G7JXvgnLBbmqCU9I0/builds/3VN5Obw95hMBphhJY/openapi.json
