# Broken Link Checker: Crawl a Site, Find 404 & Dead Links (`forgeloop/broken-link-checker`) Actor

Crawl a website and find broken links, 404 pages, dead external links and redirects. Shows the page each broken link is on and its anchor text. Respects robots.txt, polite to your server. For SEO audits, site migrations and QA. Pay per crawled page.

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

## Pricing

from $2.00 / 1,000 pages

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 Site, Find 404 & Dead Links

Crawl a website and find every broken link, missing image, stylesheet and script. Enter the home page, get back one item per crawled page with the links on it that return 404, 410, a server error, a timeout or a dead domain, together with the link text, so you know exactly what to fix and where.

### What it does

- **Crawls your site** from the start URL, following links on the same host name. `www` and the bare domain count as one site, other subdomains do not.
- **Checks every link it finds:** `a[href]`, images (`img[src]`), stylesheets (`link[rel=stylesheet]`) and scripts (`script[src]`), internal and external.
- **External links are checked, never crawled.** One request per external URL.
- **Each unique URL is checked only once** per run, even when it appears on hundreds of pages. Internal pages that are crawled anyway reuse that answer.
- **Fewer false alarms:** a fast `HEAD` request first, and every failure is confirmed with a `GET`, because many servers answer `HEAD` wrongly. External sites that refuse automated checks (401, 403, 429, LinkedIn's 999) are listed separately as `blockedLinks` instead of being reported as broken.
- **Follows redirects** and reports where they end, when you ask for working links too.
- **Respects robots.txt** of the crawled site, including `Crawl-delay` up to 10 seconds. Pages that robots.txt disallows are not requested.
- **Polite:** at most 2 parallel requests per host, a short pause between requests, and a User-Agent that names the tool. A host that times out 3 times is given up, so one dead server does not stall the run.
- Plain HTTP, no browser. A summary with totals is saved as `OUTPUT` in the key-value store.

### Use cases

- **SEO agencies:** broken links waste crawl budget and hurt user signals. Run it before an audit or monthly for every client.
- **Site owners and editors:** find links to deleted pages, moved partner sites and images that no longer load, after a relaunch, a CMS migration or a domain change.
- **Developers:** catch missing CSS and JS files and broken asset paths after a deployment.
- **Sales research:** a list of broken links on a prospect's site is a concrete reason for a first contact.

### Input

| Field | Description | Default |
|---|---|---|
| Start URLs | Pages where the crawl starts, usually the home page | |
| Max pages per site | Pages crawled per site, up to 5,000 | 200 |
| Check external links | Also check links to other websites (never crawled) | on |
| Include working links | Add an `okLinks` list with every working link and redirect target | off |
| Request timeout | Seconds before a page or link counts as timed out | 20 |
| Parallel pages | Pages processed at the same time, 1 to 20 | 5 |

### Output

One dataset item per crawled page:

```json
{
  "pageUrl": "https://example.com/blog/launch",
  "finalUrl": "https://example.com/blog/launch",
  "statusCode": 200,
  "title": "We launched | Example",
  "checkedLinks": 84,
  "brokenLinkCount": 2,
  "brokenLinks": [
    { "url": "https://example.com/pricing-old", "status": 404, "error": "Not found", "type": "link", "internal": true, "anchorText": "see our pricing" },
    { "url": "https://partner-that-closed.example/", "status": null, "error": "Domain not found", "type": "link", "internal": false, "anchorText": "our partner" }
  ],
  "blockedLinks": [
    { "url": "https://www.linkedin.com/company/example", "status": 999, "error": "Request denied", "type": "link", "internal": false, "anchorText": "LinkedIn" }
  ],
  "skippedLinks": 0,
  "error": null
}
```

- `type` is `link`, `image`, `stylesheet` or `script`.
- `status` is the final HTTP status after redirects, `null` for network errors such as `Domain not found`, `Connection refused`, `Timed out` or SSL problems.
- `skippedLinks` counts links that were not requested: internal links that robots.txt disallows, and links to an external host beyond the first 150 per run.
- `okLinks` is added when "Include working links" is on.
- The dataset view "Broken links" lists one row per broken link with the page it was found on, ready for a spreadsheet.

A page that cannot be crawled (for example an internal page that returns 404) gets an item with `error` and is not charged. The summary in the key-value store record `OUTPUT` holds pages checked, unique links checked, unique broken links, broken links by status and the run time.

### Pricing

Pay per checked page. All links checked on that page are included. Pages that fail, redirect to another site or are not HTML are not charged. Set "Max pages per site" and the maximum charge per run in Apify to cap the cost.

Each run also has a start fee of 0.00005 USD per GB of memory, which Apify shows as Actor Start.

### Speed

The crawler is deliberately polite to your server: about 5 to 10 requests per second per host. A site with 200 pages and 2,000 unique links usually takes 5 to 10 minutes. External links are checked in parallel across hosts.

### Limits

- Links that are created only by JavaScript are not seen, because pages are read without a browser.
- Links in CSS files (`url(...)`), `srcset`, iframes and PDFs are not checked.
- Pages larger than 10 MB and more than 2,000 links per page are not fully processed.
- At most 150 links per external host are checked in one run (for example GitHub links on a changelog page). Further links to that host count as skipped.
- Some sites answer automated requests with 403 or 429 even when the link works in a browser. External links with these answers are listed as `blockedLinks`. Internal links with these answers count as broken, because the crawled site should not block itself.
- Sites behind a login are not supported.
- Only public `http` and `https` addresses. Local and private network addresses are refused, also after redirects, and listed as broken if a page links to them.

### Data source, permitted use and legal

- **Data source:** Public pages of the website you enter and the links found on them.
- **Snapshot:** Results show the source at the time of the run. We do not guarantee that they are complete, current or correct.
- **For business use:** This Actor is offered to businesses only, not to consumers.
- **Permitted use:** Process only content you are allowed to access and use, for example your own websites and documents or public pages you have a legitimate reason to process. Respect the terms of the websites and the rights in the content.
- **Your responsibility:** You choose the URLs and decide what happens with the results. If results contain personal data, you are the controller and need your own legal basis.
- **No circumvention:** The Actor does not log in, solve captchas or bypass paywalls, bot protection or other access restrictions. Do not use it for that.
- **Request volume:** Respects robots.txt and Crawl-delay, at most 2 parallel requests per host, a short pause between requests, and the page limit you set. Do not use it to put excessive load on a website.
- **Provider:** forgeloop, Markus Heiss, Austria. [Imprint](https://devhem.github.io/forgeloop-legal/imprint.html), [Privacy Notice](https://devhem.github.io/forgeloop-legal/privacy.html), [Terms of Use](https://devhem.github.io/forgeloop-legal/terms.html).

### Questions and issues

Open an issue on the Actor page.

# Actor input Schema

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

Pages where the crawl starts, usually the home page. The crawler follows links on the same host name (www and non-www count as one site). A missing https:// is added automatically. Format: a list of objects with a url key, like \[{"url": "https://example.com"}]. Plain strings are not accepted.

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

Stop crawling a site after this many pages. Every checked page is one charged result, the links on it are included.

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

Also check links to other websites. They are checked once each, but never crawled.

## `includeOkLinks` (type: `boolean`):

Add an okLinks list with every working link of each page, including where redirects end. Off keeps the output small and lists only problems.

## `timeoutSeconds` (type: `integer`):

A page or link that does not answer within this time counts as broken (timeout).

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

How many pages are processed at the same time. Each host still gets at most 2 parallel requests with a short pause in between, and a crawl delay from robots.txt is respected.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://crawlee.dev"
    }
  ],
  "maxPages": 200,
  "checkExternalLinks": true,
  "includeOkLinks": false,
  "timeoutSeconds": 20,
  "maxConcurrency": 5
}
```

# Actor output Schema

## `results` (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": [
        {
            "url": "https://crawlee.dev"
        }
    ]
};

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

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

```

## MCP server setup

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