# Broken Link Checker: 404s, Errors & Redirects (`ailu_studio/broken-link-checker`) Actor

Crawl public website pages and find broken links, timeouts and redirect chains. Export source-page evidence for SEO and content maintenance.

- **URL**: https://apify.com/ailu_studio/broken-link-checker.md
- **Developed by:** [Ailu Studio](https://apify.com/ailu_studio) (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 $2.00 / 1,000 problem link rows

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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, Errors & Redirects

Crawl public website pages and find broken links, timeouts and redirect chains. Export source-page evidence for SEO and content maintenance.

### Try a small sample

Paste this into the Input JSON editor, run the Actor, then inspect its dataset. Export JSON or CSV from the dataset, or use the API tab for authenticated integration examples.

```json
{
  "startUrls": [
    "https://the-internet.herokuapp.com/status_codes"
  ],
  "maxPages": 1,
  "maxDepth": 0,
  "maxItems": 20
}
```

### Workflow example

Review HTTP failures with the source page and anchor. Some sources block automated requests; a timeout or 403 needs manual verification before deleting a link.

```json
{
  "startUrls": [
    "https://the-internet.herokuapp.com/status_codes"
  ],
  "maxPages": 1,
  "maxDepth": 0,
  "reportRedirects": true,
  "maxItems": 20
}
```

Examples show supported inputs, not guaranteed result counts. Public sources and filters can produce fewer rows or zero rows. Check the run log and any summary/error records before treating the output as complete.

For recurring use, save the input as an Apify Task and schedule sequential runs. Export results to your own spreadsheet, database, n8n or Make workflow. Scheduling does not add stateful tracking to Actors that only return snapshots. Keep API credentials in environment variables.

### Related workflow

[Sitemap URL Extractor: SEO URL Inventory](https://apify.com/ailu_studio/sitemap-url-extractor) can complement this Actor. It runs separately and has its own price and input requirements.

### Detailed reference

### Broken Link Checker: Find 404s, Dead External Links and Redirect Chains on Any Website

Crawl your website and find every broken link: 404 and 410 pages, 5xx server errors, timeouts, DNS failures, redirect loops and dead external links, each with the page it appears on and its anchor text. The Actor crawls breadth-first from your start URLs (same host only, robots.txt obeyed), collects all `<a href>` links (optionally images, scripts and stylesheets too), and checks each unique URL once with HEAD (GET when HEAD is refused) while following redirects by hand, so every row carries the full redirect chain. Compared with other broken link checkers in the Store, you pay only for problem links that are returned, not for every link checked, redirect chains are recorded hop by hop, and a free summary row reports pages crawled, links checked, broken links and redirects.

### Use cases

- SEO and site maintenance: find 404s and dead outbound links before search engines and visitors do.
- Content migrations: verify that old URLs redirect correctly and list internal links that still point at redirects (`reportRedirects`).
- Agencies and QA: run scheduled link audits of client sites and export the problems as CSV or JSON.
- Documentation and blogs: catch rotting external references in large article archives.

### Input

| Field | Default | Meaning |
|---|---|---|
| `startUrls` | `["https://the-internet.herokuapp.com/status_codes"]` | Pages to start from. Only these hosts are crawled (`www.` ignored). The default is a public test page that links to 200, 301, 404 and 500 responses. |
| `maxPages` | `20` | HTML pages to crawl at most (max 500). |
| `maxDepth` | `3` | Clicks away from the start URLs; `0` checks only the links on the start pages. |
| `checkExternal` | `true` | Also check links to other hosts (never crawled). |
| `checkAssets` | `false` | Also check `<img src>`, `<script src>` and `<link href>` (stylesheet, icon, preload, manifest). |
| `reportOnlyBroken` | `true` | Return only problem links; off returns every checked link occurrence. |
| `reportRedirects` | `false` | Also return working links that redirect at least once. |
| `maxItems` | `500` | Maximum charged link rows. |

Example input:

```json
{ "startUrls": ["https://www.example.com/"], "maxPages": 200, "maxDepth": 4, "checkAssets": true, "reportRedirects": true, "maxItems": 2000 }
```

### Output

One row per problem link occurrence: the same dead URL linked from three pages gives three rows (each with its own `sourcePage` and `anchorText`), but it is requested only once.

| Field | Type | Meaning |
|---|---|---|
| `id` | string | SHA-1 of `sourcePage + url`, first 16 hex characters. |
| `rowType` | string | `link` (charged) or `summary` (free). |
| `url` | string | Absolute link target (fragment removed). |
| `sourcePage` | string | Page that contains the link. |
| `anchorText` | string | null | Link text, aria-label, title or image alt. |
| `linkType` | string | `internal`, `external` or `asset`. |
| `statusCode` | integer | null | Final HTTP status; null on network errors. |
| `finalUrl` | string | Where the redirects ended. |
| `redirectChain` | object\[] | `[{url, status}]` per hop, including the final answer. |
| `redirectCount` | integer | Number of 3xx hops. |
| `error` | string | null | `timeout`, `DNS lookup failed`, `redirect loop`, `too many redirects`, `redirect without a Location header`, ... |
| `isBroken` | boolean | Status >= 400 (except 429), network error, timeout or redirect problem. |
| `checkedAt`, `fetchedAt` | ISO 8601 | Check time and run start. |

Sample row:

```json
{
  "id": "d673203377095985", "rowType": "link", "url": "https://the-internet.herokuapp.com/status_codes/404",
  "sourcePage": "https://the-internet.herokuapp.com/status_codes", "anchorText": "404", "linkType": "internal",
  "statusCode": 404, "finalUrl": "https://the-internet.herokuapp.com/status_codes/404", "redirectChain": [], "redirectCount": 0,
  "error": null, "isBroken": true, "checkedAt": "2026-11-04T11:44:33.906Z", "fetchedAt": "2026-11-04T11:44:32.811Z"
}
```

Summary row (free):

```json
{ "id": "summary:https://the-internet.herokuapp.com/status_codes", "rowType": "summary", "pagesCrawled": 5, "pagesFailed": 3, "linksFound": 9, "linksChecked": 9, "broken": 3, "redirects": 3, "skippedByRobots": 0, "skippedExternal": 0, "notCheckedCap": 0, "durationSecs": 3.5, "errors": [] }
```

### How it works and limits

- Crawl: breadth-first by depth; within one depth level pages are picked round-robin across URL sections, so a small `maxPages` samples different page templates. Only `text/html` pages with status 200 on the start hosts are parsed; links inside HTML comments, scripts and styles are ignored; `mailto:`, `tel:`, `javascript:` and `#fragment` links are skipped.
- Checks: HEAD first, GET (body not downloaded) when HEAD answers 403, 405 or 501. Redirects are followed manually up to 10 hops; a repeated URL is a redirect loop. Timeout is 15 s per request; 5xx and network errors are retried once.
- Politeness: robots.txt (`User-agent: *` or `apify-actor-broken-link-checker`) is obeyed for every host the Actor fetches from, including `Crawl-delay` (up to 10 s). Requests to the crawled site are spaced at least 250 ms apart, to each external host 500 ms, with at most 3 parallel requests per host. Expect about 4 checked links per second on one site.
- Hard cap: 2,000 checked URLs per run (pages plus links); the summary row reports how many were left out. Split very large sites into several runs by start URL.
- Limits: no JavaScript rendering (links added by client-side scripts are not seen), no login, forms are never submitted. Some sites block automated checks (for example with 403 or 999 answers from bot protection); such links are reported as broken with their real status, so review them manually. 429 answers are returned with a note but not counted as broken.

### Pricing

Pay per result: **$2.00 per 1,000 rows** (`link` event). Platform usage is billed separately by Apify. Removed/free rows are not charged.

Only returned link rows are charged. With `reportOnlyBroken` on (default) you pay for problems found, not for the links that work; the summary row is free.

### Legal

Not affiliated with the websites you check. Uses the public web pages and robots.txt files of the sites you choose only, identifies itself with the User-Agent `apify-actor-broken-link-checker/0.1 (+https://apify.com)` and never logs in or submits forms. Data licence/terms: https://www.rfc-editor.org/rfc/rfc9309 (Robots Exclusion Protocol) and the terms of use of each site you audit; check only sites you own or are allowed to audit.

### FAQ

**Why do some working links show up as broken?** A few sites refuse automated requests (403, 999) or need JavaScript. The row shows the exact status the site returned; open the link in a browser to confirm.

**Why was a page not crawled?** It was disallowed by robots.txt (`skippedByRobots`), deeper than `maxDepth`, beyond `maxPages`, not HTML, or on another host.

**How do I find links that should be updated after a migration?** Turn on `reportRedirects`: every link that redirects is returned with `redirectChain` and `finalUrl`, so you can replace it with the final URL.

**Does it check every occurrence of a link?** Each unique URL is requested once; the result is reported for every page that links to it.

**Can I check a list of URLs without crawling?** Set `maxDepth` to `0` and give the pages whose links you want checked as `startUrls`.

# Actor input Schema

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

Pages to start crawling from, e.g. "https://www.example.com/". Only pages on these hosts are crawled (www. and non-www. count as the same host); links to other hosts are checked but not crawled.

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

Upper limit on HTML pages fetched and parsed for links. Links found on them are checked on top of this (at most 2,000 checked links per run).

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

How many clicks away from the start URLs pages are crawled. 0 checks only the links on the start pages.

## `checkExternal` (type: `boolean`):

Also check links that point to other websites (they are never crawled). Requests to each external host are spaced 500 ms apart, at most 3 at a time.

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

Also check <img src>, <script src> and <link href> (stylesheet, icon, preload, manifest) URLs. They are reported with linkType "asset".

## `reportOnlyBroken` (type: `boolean`):

On: return only problem links (broken, or redirecting when that option is on). Off: return every checked link occurrence, including working ones. Every returned link row is billed.

## `reportRedirects` (type: `boolean`):

Also return links that work but redirect at least once, with the full redirect chain, so you can update them to the final URL.

## `maxItems` (type: `integer`):

Upper limit on charged link rows. The free summary row does not count. Checking stops once the limit is reached.

## Actor input object example

```json
{
  "startUrls": [
    "https://the-internet.herokuapp.com/status_codes"
  ],
  "maxPages": 20,
  "maxDepth": 3,
  "checkExternal": true,
  "checkAssets": false,
  "reportOnlyBroken": true,
  "reportRedirects": false,
  "maxItems": 500
}
```

# Actor output Schema

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

All rows in the default dataset.

# 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://the-internet.herokuapp.com/status_codes"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ailu_studio/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://the-internet.herokuapp.com/status_codes"] }

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

```

## MCP server setup

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