# Broken Link Checker: 404s, Redirect Chains & Soft 404s (`kayorama/broken-link-checker`) Actor

Crawl your website and find broken links, images, scripts and CSS. Get status codes, full redirect chains, soft 404 hints, the page and anchor text for every link, and a run summary.

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

## Pricing

$0.50 / 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: 404s, Redirect Chains & Soft 404s

Point it at your website and it tells you which links are dead. The Actor crawls your pages, collects every link, image, script and stylesheet on them, and checks each unique URL once. You get the status code, the page it was found on, the anchor text, and the full redirect chain when a link bounces through one or more redirects.

It also flags soft 404s: pages that answer 200 OK but say "Page not found" in the title or heading, and old URLs that quietly redirect to your home page. Most link checkers report those as fine.

At the end of every run there's a summary in the key-value store with pages crawled, links checked, broken links by status code, the worst offenders, and the pages with the most problems.

No login, no proxy, no browser. Plain HTTP, a declared user agent, and a polite pace.

### Good for

- **Site maintenance:** find the 404s in your menus, footers and old blog posts before your visitors do.
- **SEO audits:** broken internal links waste crawl budget and leak link equity. Redirect chains slow everything down. Both show up here with the exact page to fix.
- **After a migration or relaunch:** run it on the new site and see every old URL that still points nowhere.
- **Agencies:** schedule a weekly check per client and send them the list of problems, sorted by how often each broken link appears.
- **Dead images and scripts:** a missing image or a script on a dead CDN also counts, and those are easy to miss by eye.

### How it works

1. It opens your start URLs and follows links on the same host (www and non-www count as one site), up to `maxPages` pages and `maxDepth` clicks deep. It respects your robots.txt and any Crawl-delay.
2. It extracts every `<a href>`, `<img src>`, `<link href>` and `<script src>`. Comments, `mailto:`, `tel:` and `javascript:` links are skipped.
3. Each unique URL is checked once. External links get a HEAD request first; if the server refuses HEAD or answers with an error, it retries with GET before calling the link broken. That cuts most of the false alarms you get from servers that handle HEAD badly. Internal pages are fetched with GET so the soft 404 check can read them.
4. Redirects are followed one hop at a time (up to 8), so you see every step and its status code, not only where it ended.
5. External links are checked, never crawled. Every host gets at least 0.8 seconds between requests, 429 and 503 answers are respected (Retry-After first, then a backoff), and your own site gets 200 ms between requests by default.

### What you get

By default you get one row per unique link. Turn on **Only output problem links** to get just the broken ones.

| Field | Example |
| --- | --- |
| `linkUrl` | https://example.com/old-pricing |
| `sourcePage`, `anchorText` | the first page it was found on and the link text there |
| `sourcePages`, `occurrences` | every page it was found on (up to 50) and how many times |
| `linkType` | `a`, `img`, `script`, `css` or `link` (icons, canonical, alternates, preload) |
| `scope` | `internal` or `external` |
| `issueType` | `broken`, `soft-404`, `blocked`, `rate-limited`, `redirect`, `not-checked` or `ok` |
| `isBroken` | true for 4xx, 5xx, DNS errors, refused connections, TLS errors and timeouts |
| `statusCode`, `finalStatusCode` | 301, 404 |
| `error` | `ENOTFOUND: getaddrinfo ENOTFOUND old-cdn.example.net`, `TIMEOUT: no response within the time limit` |
| `isRedirect`, `redirectCount`, `redirectChain`, `finalUrl` | every hop with its status |
| `soft404Hint` | `Page title says "Page not found"`, `Redirects to the home page` |
| `nofollow`, `rel` | from the link's rel attribute |
| `mixedContent` | an http image, script or stylesheet on an https page |
| `method`, `contentType`, `responseMs` | how the check was done |

Example row:

```json
{
    "sourcePage": "https://example.com/blog/2021-roundup",
    "linkUrl": "https://example.com/tools/old-calculator",
    "anchorText": "our ROI calculator",
    "linkType": "a",
    "scope": "internal",
    "issueType": "broken",
    "isBroken": true,
    "statusCode": 301,
    "finalStatusCode": 404,
    "error": null,
    "isRedirect": true,
    "redirectCount": 2,
    "redirectChain": [
        { "from": "https://example.com/tools/old-calculator", "status": 301, "to": "https://example.com/tools/old-calculator/" },
        { "from": "https://example.com/tools/old-calculator/", "status": 301, "to": "https://example.com/calculators/roi" }
    ],
    "finalUrl": "https://example.com/calculators/roi",
    "soft404Hint": null,
    "nofollow": false,
    "occurrences": 6,
    "sourcePages": ["https://example.com/blog/2021-roundup", "https://example.com/pricing"]
}
```

#### The SUMMARY record

Open the key-value store of the run and look for `SUMMARY`:

```json
{
    "pagesCrawled": 20,
    "uniqueLinksFound": 650,
    "linksChecked": 650,
    "internalLinksChecked": 640,
    "externalLinksChecked": 10,
    "brokenLinks": 3,
    "brokenByStatus": { "404": 2, "ENOTFOUND": 1 },
    "soft404Links": 1,
    "blockedLinks": 0,
    "redirectedLinks": 12,
    "byStatusCode": { "200": 634, "404": 2, "no response": 1 },
    "topBrokenLinks": [{ "linkUrl": "https://example.com/old", "status": 404, "occurrences": 14 }],
    "pagesWithMostProblems": [{ "page": "https://example.com/resources", "problems": 3 }],
    "stopReason": null
}
```

### Input

| Field | Default | What it does |
| --- | --- | --- |
| `startUrls` | crawlee.dev | Where the crawl starts. Usually your home page. |
| `maxPages` | 5 | Pages to open and read links from. Raise it for a full site check. |
| `maxDepth` | 3 | Clicks away from the start URL. 0 checks only the links on the start pages. |
| `maxLinksToCheck` | 200 | Cap on unique links checked (and paid for) per run. |
| `checkExternalLinks` | true | Check links to other sites too. |
| `checkResources` | true | Check images, scripts and stylesheets, not only `<a>` links. |
| `onlyBroken` | false | Only write problem links to the dataset. |
| `includeRedirects` | false | With `onlyBroken`, also report links that work but redirect. |
| `includeBlocked` | true | With `onlyBroken`, also report 401, 403, 429 and 999 answers. |
| `rowPerSourcePage` | false | One row per page and link instead of one per unique link. |
| `ignoreUrlPatterns` | none | Skip links containing this text, or matching `/regex/`. |
| `timeoutSecs` | 10 | No answer in this time means a TIMEOUT error. |
| `requestDelayMs` | 200 | Pause between requests to your own site. |

The defaults are small on purpose so a first try costs about 10 cents. For a real site check, something like this works well:

```json
{
    "startUrls": ["https://www.example.com"],
    "maxPages": 500,
    "maxDepth": 10,
    "maxLinksToCheck": 5000,
    "onlyBroken": true,
    "includeRedirects": true,
    "ignoreUrlPatterns": ["/wp-admin/", "?replytocom=", "/cart"]
}
```

### Pricing

Pay per event, no start fee:

| Event | Price |
| --- | --- |
| Link checked (one unique URL requested, crawled pages included) | $0.0005 |

You pay once per unique URL, no matter how many pages link to it. A link on every page of your site is one event. Links skipped by your ignore patterns, links blocked by your robots.txt and links left over when a cap is hit are not charged. Rows in the dataset are free, so `onlyBroken` on or off costs the same.

Some examples: the default run (200 links) costs $0.10. A 300-page site with 2,000 unique links costs $1.00. If you set a maximum cost per run, the Actor stops checking when it gets there and still writes the results and the summary.

### FAQ

**Why is a link marked `blocked` and not broken?**
401, 403, 429 and 999 usually mean the other site doesn't let automated checks in (LinkedIn answers 999, many shops sit behind bot protection). The link might work fine in a browser. They're listed separately so you can check them by hand. Turn off `includeBlocked` to hide them.

**Does it crawl external sites?**
No. External links get a status check and nothing more. Only pages on the start URL's host are crawled.

**Does it respect robots.txt?**
Yes for your own site: pages and internal links your robots.txt disallows for our crawler are not requested and show up as `not-checked`. External links get a single status check, like a visitor clicking the link, at a slow pace per host.

**Can it check pages that need JavaScript?**
It reads the HTML the server sends. Links that only appear after JavaScript runs are not seen. Most sites (WordPress, Shopify, Webflow, Next.js and Docusaurus with server rendering) send their links in the HTML.

**How reliable is the soft 404 hint?**
It's a hint. It fires when a 200 page has "404", "not found" or a similar phrase (also in Dutch, German, French, Spanish, Italian, Polish and Portuguese) in the title or main heading, or when a deep URL redirects to the home page. Look at those rows before you change anything.

**How fast is it?**
Your site gets about 5 requests per second by default; external hosts are checked in parallel at a slower pace each. Expect roughly 250 to 300 links per minute on a normal site. Raise `requestDelayMs` if your server is small.

**What user agent does it send?**
`Mozilla/5.0 (compatible; KayoramaLinkChecker/0.1; +https://apify.com/kayorama/broken-link-checker)`. You can target `KayoramaLinkChecker` in robots.txt.

### Support

Found a bug or want another check? Open an issue on the Actor's Issues tab and I'll take a look. Made by Kayorama.

# Actor input Schema

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

Pages to start crawling from, for example your home page. The crawler stays on the same host (www. and non-www count as one). One per line.

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

How many internal HTML pages to open and read links from. Links found on those pages are all checked, so the number of checked links is usually much higher.

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

How many clicks away from a start URL the crawler goes. 0 checks only the links on the start pages.

## `maxLinksToCheck` (type: `integer`):

Safety cap on unique links checked per run (each one is a paid event). The run stops cleanly when it is reached and still writes the summary.

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

Also check links that point to other websites. They are checked with HEAD (GET if needed) and never crawled.

## `checkResources` (type: `boolean`):

Check <img src>, <script src> and <link href> as well as normal <a href> links.

## `onlyBroken` (type: `boolean`):

On: one row per broken link, soft 404 and (optionally) blocked or redirected link. Off: one row for every checked link, also the ones that work.

## `includeRedirects` (type: `boolean`):

With 'Only output problem links' on, also output links that work but go through one or more redirects. Handy for cleaning up old URLs in menus and content.

## `includeBlocked` (type: `boolean`):

With 'Only output problem links' on, also output links that answered 401, 403, 429 or 999. These are often bot protection on the other site, not real dead links, so check them by hand.

## `rowPerSourcePage` (type: `boolean`):

Off: one row per unique link, with the pages it was found on in sourcePages. On: one row for every page the link appears on, with that page's anchor text.

## `ignoreUrlPatterns` (type: `array`):

Links containing any of these are not crawled or checked. Plain text matches anywhere in the URL (for example /wp-admin/ or ?replytocom=). Wrap in slashes for a regular expression, for example /.pdf$/.

## `timeoutSecs` (type: `integer`):

A link that gives no answer within this time is reported as broken with a TIMEOUT error.

## `requestDelayMs` (type: `integer`):

Minimum time between two requests to the crawled site. External sites always get at least 1 second between requests, and a robots.txt Crawl-delay is respected.

## Actor input object example

```json
{
  "startUrls": [
    "https://crawlee.dev"
  ],
  "maxPages": 5,
  "maxDepth": 3,
  "maxLinksToCheck": 200,
  "checkExternalLinks": true,
  "checkResources": true,
  "onlyBroken": false,
  "includeRedirects": false,
  "includeBlocked": true,
  "rowPerSourcePage": false,
  "ignoreUrlPatterns": [],
  "timeoutSecs": 10,
  "requestDelayMs": 200
}
```

# Actor output Schema

## `links` (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://crawlee.dev"
    ],
    "ignoreUrlPatterns": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("kayorama/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://crawlee.dev"],
    "ignoreUrlPatterns": [],
}

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

```

## MCP server setup

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