# Broken Link Checker: 404s, 5xx & Redirect Chains (robots.txt) (`mrlarryjohnson/broken-link-checker`) Actor

Crawl your own website and find every broken link: 404 and other 4xx errors, 5xx server errors, timeouts, redirect chains and loops, plus dead external links, with the page each one was found on and its anchor text. Respects robots.txt and Crawl-delay. CSV report included.

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

## Pricing

from $0.50 / 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/running/actors-in-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 Checker: 404s, 5xx & Redirect Chains (robots.txt)

Point it at **your own website** and get a full link-health report in minutes:

- **Broken links:** 404 / 410 and other 4xx, **5xx server errors**, timeouts, dead domains (DNS), connection failures
- **Redirects:** every hop of each **redirect chain** (301 → 302 → 200), **redirect loops**, HTTPS → HTTP downgrades
- **Where to fix it:** the page each broken link was found on, plus its **anchor text**
- **External links** to other sites verified too (free), with bot-walled responses (401/403/429/999) marked `ACCESS_RESTRICTED` instead of falsely "broken"
- Optional checks for **images, scripts, stylesheets, iframes and canonical URLs**
- A ready-to-share **CSV** of every broken link (`BROKEN_LINKS_CSV` in the key-value store) and a run **SUMMARY**

It behaves like a polite search-engine crawler: it reads and obeys **robots.txt** (including `Crawl-delay`) for every host it contacts, identifies itself as `ApifyBrokenLinkChecker`, and caps parallel requests.

### Use cases

- **SEO audits:** fix 404s and redirect chains that waste crawl budget and link equity
- **Site migrations and redesigns:** schedule weekly and catch regressions before visitors do
- **Agencies:** one report per client site, exported to Sheets or Slack
- **Docs and blogs:** find outbound links that rotted years ago

### Input

| Field | Default | Notes |
|---|---|---|
| `startUrls` | — | A site you own or manage. www and non-www count as one site |
| `maxPages` | `500` | URLs on your site to request (up to 20,000) |
| `maxDepth` | `10` | Clicks from the start page |
| `checkExternalLinks` | `true` | HEAD, then GET fallback |
| `maxExternalLinks` | `500` | Distinct external URLs |
| `checkAssets` | `false` | img/script/css/iframe/canonical |
| `includeSubdomains` | `false` | Crawl `*.yoursite.com` too |
| `excludeUrlPatterns` | — | Substrings or globs to skip |
| `maxConcurrency` | `5` | Crawl-delay in robots.txt wins |

### Output

One dataset row per checked URL (your pages, assets and external links):

```json
{
  "url": "https://example.com/old-pricing", "type": "page", "depth": 2,
  "foundOn": "https://example.com/blog/launch", "anchorText": "see our pricing",
  "statusCode": 404, "finalUrl": "https://example.com/pricing-2024",
  "redirectChain": [{"url": "https://example.com/old-pricing", "statusCode": 301}],
  "redirectCount": 1, "responseTimeMs": 182, "linksFound": 0,
  "issues": ["BROKEN_4XX", "REDIRECT"], "error": null
}
```

Issue codes: `BROKEN_4XX`, `SERVER_ERROR_5XX`, `TIMEOUT`, `DNS_FAILED`, `CONNECT_FAILED`, `REDIRECT`, `REDIRECT_CHAIN`, `REDIRECT_LOOP`, `TOO_MANY_REDIRECTS`, `HTTPS_TO_HTTP_REDIRECT`, `ACCESS_RESTRICTED`, `BLOCKED_BY_ROBOTS`, `ROBOTS_TXT_UNAVAILABLE`, `URL_NOT_ALLOWED`, `PAGE_TRUNCATED`.

Key-value store: `SUMMARY` (totals), `BROKEN_LINKS` (JSON) and `BROKEN_LINKS_CSV`: one line per *source page → broken URL* pair.

### Pricing (pay per event)

- **$0.50 per 1,000 pages** (`page-crawled`, $0.0005 per URL on your site that responded), plus the standard $0.00005 actor start.
- **Free:** external link checks, URLs skipped by robots.txt or your exclude patterns, and requests that got no response at all.
- Respects your run's maximum cost, so a 10,000-page site never costs more than you set.

### Fair use

- Crawl only websites you own or are authorized to audit. The crawl never leaves the start site (except single checks of external links).
- robots.txt is always honored. A robots.txt that returns a 5xx error is treated as "disallow all", per RFC 9309. To let this checker into areas you block for other bots, add `User-agent: ApifyBrokenLinkChecker` rules.
- `mailto:` and `tel:` links are ignored, and no contact data is collected. Private-network addresses are blocked.

***

*Actively maintained. Issues answered within 24 hours on the Issues tab.*

# Actor input Schema

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

Home page (or any page) of a website you own or manage. The crawl stays on that site (www and non-www count as the same site). Up to 20 start URLs.

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

Maximum number of URLs on your site to request. Each one is a `page-crawled` event.

## `maxDepth` (type: `integer`):

How many clicks away from the start URL to follow (0 = start page only).

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

Also verify links that point to other websites (one HEAD request each, GET as fallback). External checks are free.

## `maxExternalLinks` (type: `integer`):

Distinct external URLs to verify per run.

## `checkAssets` (type: `boolean`):

Also check <img>, <script>, <iframe>, <source>, stylesheet, icon and canonical URLs, not just <a href> links.

## `includeSubdomains` (type: `boolean`):

Treat blog.example.com, shop.example.com etc. as part of the site and crawl them too.

## `excludeUrlPatterns` (type: `array`):

Skip URLs on your site that contain one of these strings or match a glob (e.g. "/tag/", "*?replytocom=*").

## `maxConcurrency` (type: `integer`):

Requests in flight at once. A robots.txt Crawl-delay always takes priority.

## Actor input object example

```json
{
  "startUrls": [
    "https://crawler-test.com/"
  ],
  "maxPages": 50,
  "maxDepth": 10,
  "checkExternalLinks": true,
  "maxExternalLinks": 500,
  "checkAssets": false,
  "includeSubdomains": false,
  "maxConcurrency": 5
}
```

# Actor output Schema

## `results` (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": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("mrlarryjohnson/broken-link-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": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("mrlarryjohnson/broken-link-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": 50
}' |
apify call mrlarryjohnson/broken-link-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mrlarryjohnson/broken-link-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/hbH2QpGUl2JYlmAUb/builds/qiavJLMFeH9GjxqZo/openapi.json
