# Broken Link Checker: Crawl a Website for 404s & Dead Links (`adam-frank/broken-link-checker`) Actor

Crawl your whole website and check every internal and external link. Get each broken link with the page it is on, anchor text, status code and redirect chain. Bot blocks (403, 429, Cloudflare) are labeled, not called broken. Pay per link checked. Works from AI agents via MCP.

- **URL**: https://apify.com/adam-frank/broken-link-checker.md
- **Developed by:** [Adam Schepis](https://apify.com/adam-frank) (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

$1.00 / 1,000 link checkeds

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: Crawl a Website for 404s & Dead Links

Crawl your whole website and check every link on it. Give it your **home page URL** and it follows internal links page by page, collects every `<a href>`, and checks each unique link once: **internal pages and outbound links to other sites**. You get one row per broken link per page, with the **page it is on, the anchor text, the HTTP status code, the error type and the full redirect chain**, so you know exactly what to fix and where.

Links that bot protection refuses (**403, 429, LinkedIn's 999, Cloudflare challenges**) are labeled `blocked`, never `broken`, so your report is not padded with links that work fine in a browser.

Works from AI agents too: call it as a tool through [Apify's MCP server](https://mcp.apify.com) when an agent is asked to "find and fix the dead links in our docs".

### What you get

- **Every broken link, with where it is:** source page, target URL, anchor text, status code, and whether it is internal or external. A link that is broken on 40 pages gives 40 rows, so each page can be fixed.
- **Clear error types:** `http-4xx`, `http-5xx`, `dns-error`, `timeout`, `tls-error`, `connection-error`, `redirect-loop`, `too-many-redirects` and more, not just "failed".
- **Redirect chains:** every hop with its status code, plus the final URL, so a link that 301s to a 404 is caught and you can see where it went wrong.
- **No false alarms from bot blocks:** 401, 403, 429, 999 and Cloudflare/AWS WAF challenge pages are reported as `blocked` with a reason, separate from real broken links.
- **Optional extras:** check `<img>` sources for broken images, check `#anchor` links against the ids on your own pages, or output every working link too for a full inventory.
- **A run summary** in the key-value store (`SUMMARY`): pages crawled, links found and checked, and counts of broken, blocked, working and skipped links.
- **Pay per unique link checked.** Pages crawled, skipped links and links over your limits are free.

### How it works

1. Crawls your site from the start URLs, staying on the same site (`example.com` and `www.example.com` count as one; turn on **Include subdomains** to add `blog.example.com` and the like). robots.txt is honored for crawling.
2. Collects every link on each page. `mailto:`, `tel:`, `javascript:` and same-page `#` links are skipped and never charged.
3. Checks each unique URL once. Pages the crawler already opened are not requested again. Other links get a `HEAD` request, and any `HEAD` failure is confirmed with a `GET` before the link counts as broken, because many servers answer `HEAD` with 404, 405 or 501 for pages that work.
4. External sites are only checked, never crawled, with at most 2 requests at a time per site.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `startUrls` | array of URLs | required | Where to start, usually your home page. |
| `maxPages` | integer | 100 | Pages of your site to open and read links from. |
| `maxLinks` | integer | 1000 | Unique links to check (and charge) at most. |
| `checkExternalLinks` | boolean | `true` | Also check links to other websites. |
| `includeSubdomains` | boolean | `false` | Treat subdomains of the start site as internal and crawl them. |
| `includeImages` | boolean | `false` | Also check `<img>` sources. |
| `checkAnchors` | boolean | `false` | Report `/page#section` links whose page has no element with that id. |
| `reportWorkingLinks` | boolean | `false` | Output a row for every link, not only broken and blocked ones. |
| `maxCostUsd` | number | none | Spending cap for this run; links beyond it are not checked or charged. |

Example input:

```json
{
    "startUrls": [{ "url": "https://the-internet.herokuapp.com/" }],
    "maxPages": 25,
    "maxLinks": 300
}
```

### Output example

One row per page and broken (or blocked) link. These are real rows from a run of the input above:

```json
{
    "sourceUrl": "https://the-internet.herokuapp.com/disappearing_elements",
    "targetUrl": "https://the-internet.herokuapp.com/portfolio/",
    "anchorText": "Portfolio",
    "element": "a",
    "linkType": "internal",
    "status": "broken",
    "statusCode": 404,
    "errorType": "http-4xx",
    "errorMessage": "HTTP 404.",
    "redirectChain": [],
    "finalUrl": "https://the-internet.herokuapp.com/portfolio/",
    "checkedWith": "GET",
    "checkedAt": "2026-11-20T15:06:10.106Z"
}
```

A link behind a login is reported, but as `blocked`, not `broken`:

```json
{
    "sourceUrl": "https://the-internet.herokuapp.com/",
    "targetUrl": "https://the-internet.herokuapp.com/basic_auth",
    "anchorText": "Basic Auth",
    "linkType": "internal",
    "status": "blocked",
    "statusCode": 401,
    "errorType": "auth-required",
    "errorMessage": "HTTP 401: the page needs a login."
}
```

Download the rows as JSON, CSV or Excel, or read them through the Apify API. The run summary is in the default key-value store under `SUMMARY`.

#### Status and error types

| `status` | `errorType` | Meaning |
|---|---|---|
| `broken` | `http-4xx` | The server answered 400-499 (other than the blocked codes below), for example 404 Not Found or 410 Gone. |
| `broken` | `http-5xx` | The server answered with an error, 500-599. |
| `broken` | `dns-error` | The domain does not resolve: a typo, or an expired domain. |
| `broken` | `timeout` | No complete answer within 20 seconds. |
| `broken` | `tls-error` | The HTTPS certificate is expired, self-signed, or for another domain. |
| `broken` | `connection-error` | The server refused or dropped the connection. |
| `broken` | `redirect-loop` / `too-many-redirects` | Redirects go in a circle, or there are more than 10. |
| `broken` | `invalid-redirect` | A redirect with no `Location` header, or to a URL that cannot be followed. |
| `broken` | `missing-anchor` | With `checkAnchors`: the page loads but the `#section` is not on it. |
| `blocked` | `bot-blocked` | 403 or LinkedIn's 999: the site refuses automated requests. |
| `blocked` | `rate-limited` | 429: the site is limiting requests. |
| `blocked` | `auth-required` | 401 or 407: the page needs a login. |
| `blocked` | `challenge-page` | A Cloudflare, AWS WAF or similar bot check. |
| `skipped` | `private-address` | The link points at a private or internal network address (`localhost`, `192.168.x.x` and so on), which is never fetched. Not charged. |

A `blocked` link usually works for a human visitor. Open it in a browser before deciding it is broken.

### Pricing

This Actor uses [pay-per-event pricing](https://docs.apify.com/platform/actors/publishing/monetize/pay-per-event). You pay for one event, `link-checked`, once per unique link that was checked. The exact price is shown on the Actor's Store page before you run it.

| Event | When it's charged |
|---|---|
| `link-checked` | Once per unique URL checked, however many pages link to it, before its rows are saved. |

- **Crawling pages is free.** You pay for links checked, not pages visited.
- **Skipped links are free:** `mailto:`, `tel:`, `javascript:`, same-page `#` links, private network addresses, external links when `checkExternalLinks` is off, and anything past `maxLinks` or `maxCostUsd`.
- **Your spending limit is respected.** Set `maxCostUsd`, `maxLinks`, or the run's maximum cost, and the Actor stops checking before it goes over.

### Good to know

- **Static HTML only.** Links are read from the HTML the server sends. Links that only appear after JavaScript runs (some single-page apps) are not seen. The same goes for `#anchors` added by JavaScript, which is why `checkAnchors` is off by default.
- **robots.txt is honored for crawling.** A page your robots.txt disallows is still checked when another page links to it (one request, like a visitor clicking), but it is not crawled for more links. If robots.txt disallows the start URL itself, nothing is crawled.
- **Only `<a href>` links by default**, plus `<area href>`. Turn on `includeImages` for `<img src>`. Stylesheets and scripts are not checked.
- **Same page, different query string = different link.** `/page?a=1` and `/page?a=2` are checked separately. Trailing slashes are kept as written, since `/docs` and `/docs/` can be different pages.
- **Private network addresses are never fetched**, including links that redirect to one, so the Actor cannot be pointed at internal services.
- **Requests use a normal browser User-Agent.** Some sites still block automated checks; those links show up as `blocked`, not `broken`.

### Why this Actor

- Bot blocks are labeled separately, so the broken-link list is one you can act on.
- Each broken link comes with the page it is on and its anchor text, so fixing it is a find-and-replace, not a hunt.
- `HEAD` failures are confirmed with `GET` before anything is reported.
- Each unique link is checked and charged once, however many pages it appears on.

### Notes

- Built with [Crawlee](https://crawlee.dev) and the [Apify SDK for JavaScript](https://docs.apify.com/sdk/js/). HTML parsing by [cheerio](https://cheerio.js.org/).
- The example input uses [The Internet](https://the-internet.herokuapp.com/), a public practice site for test automation that has broken links on purpose.

# Actor input Schema

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

Where to start crawling, usually your home page. Every page on the same site that can be reached by following links is crawled, up to "Max pages". "example.com" and "www.example.com" count as the same site. Add more URLs to start from sections that are not linked from the home page.

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

How many pages of your site to open and read links from. Pages are free; you pay per unique link checked.

## `maxLinks` (type: `integer`):

Stop after this many unique links (URLs). Each unique link is checked and charged once, however many pages it is on. Links found after the limit are counted in the summary but not checked or charged.

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

Also check links that point to other websites. External sites are never crawled, only checked, with at most 2 requests at a time per site. Turn off to check internal links only.

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

Treat subdomains of the start URL's site (blog.example.com, docs.example.com) as internal and crawl them too. Off by default.

## `includeImages` (type: `boolean`):

Also check <img> sources, so broken images are reported. Each unique image URL counts as one checked link.

## `checkAnchors` (type: `boolean`):

Report internal links such as /guide#setup where the page loads but has no element with that id. Free: it uses pages already crawled. Off by default because anchors added by JavaScript are not seen.

## `reportWorkingLinks` (type: `boolean`):

Output a row for every link, not just broken and blocked ones. Useful for a full link inventory.

## `maxCostUsd` (type: `number`):

Optional spending cap for this run, in US dollars. The run checks only as many links as this buys and leaves the rest unchecked and uncharged. Leave empty to rely on "Max links to check" and the platform's own per-run cost limit.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://the-internet.herokuapp.com/"
    }
  ],
  "maxPages": 25,
  "maxLinks": 300,
  "checkExternalLinks": true,
  "includeSubdomains": false,
  "includeImages": false,
  "checkAnchors": false,
  "reportWorkingLinks": false
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset with one row per page and link: source page, target URL, anchor text, status, status code, error type and redirect chain.

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

Totals for the run: pages crawled, links found and checked, and how many were broken, blocked, working or skipped.

# 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": [
        {
            "url": "https://the-internet.herokuapp.com/"
        }
    ],
    "maxPages": 25,
    "maxLinks": 300
};

// Run the Actor and wait for it to finish
const run = await client.actor("adam-frank/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": [{ "url": "https://the-internet.herokuapp.com/" }],
    "maxPages": 25,
    "maxLinks": 300,
}

# Run the Actor and wait for it to finish
run = client.actor("adam-frank/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": [
    {
      "url": "https://the-internet.herokuapp.com/"
    }
  ],
  "maxPages": 25,
  "maxLinks": 300
}' |
apify call adam-frank/broken-link-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,adam-frank/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/eTZ5k4HRNQDtUKBsk/builds/Pq62478MX4puf1JHN/openapi.json
