# Broken Link Checker — Find 404s & Redirects Site-Wide (`moha-tah/broken-link-checker`) Actor

Crawl a website and check every link: broken (404, 5xx, DNS, timeout), redirected links and their chains, with the pages and anchor text where each link appears. Internal and external links, optional images/scripts/CSS. Pay per link checked.

- **URL**: https://apify.com/moha-tah/broken-link-checker.md
- **Developed by:** [Mohamed T.](https://apify.com/moha-tah) (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

Pay per event

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 — Find 404s & Redirects Site-Wide

**Crawl a website and get every broken link, every redirect, and the exact pages (with anchor text) where each one appears.** Pay only per link checked, from $0.0005.

### Who it's for

- **SEO agencies and consultants** running technical audits or post-migration checks.
- **Site owners and content teams** who want a weekly broken-link report (schedule it on Apify).
- **Developers** adding a link check to CI or to an n8n / Make / Zapier workflow through the Apify API.

### What it does

1. Starts from the pages you give (usually the homepage) and crawls the same site (`www.` and bare domain count as one site), up to *Max pages to crawl per site*.
2. Extracts every `<a href>` link (optionally `<img>`, `<script>` and stylesheets too).
3. Checks each **unique** link once, internal and external, following redirects by hand to record the full chain.
4. Outputs one row per link with its verdict and up to 5 pages that link to it, plus the anchor text and `nofollow` flag.

#### Verdicts (the `status` field)

| status | meaning |
|---|---|
| `ok` | 2xx/3xx final response, no redirect |
| `redirected` | works, but through one or more redirects (update the link to the final URL) |
| `broken` | 404/410/5xx, DNS failure, timeout, TLS error, redirect loop |
| `blocked` | 401/403/429/999: the site refuses crawlers or requires a login. It usually works in a browser, so it is **not** counted as broken (no false alarms from LinkedIn, npm, Stack Overflow…) |
| `skipped` | robots.txt disallows fetching it. Reported but **not billed** |

### Input example

```json
{
  "startUrls": ["https://books.toscrape.com"],
  "maxPagesPerSite": 10,
  "checkExternalLinks": true,
  "checkResources": false,
  "onlyProblems": false
}
```

### Output example

```json
{
  "url": "https://example.com/old-pricing",
  "status": "broken",
  "broken": true,
  "linkType": "link",
  "internal": true,
  "statusCode": 404,
  "finalUrl": "https://example.com/old-pricing",
  "finalStatusCode": 404,
  "redirectCount": 0,
  "redirectChain": [],
  "responseTimeMs": 87,
  "error": "HTTP 404",
  "foundOnCount": 3,
  "foundOn": [
    {"page": "https://example.com/", "anchorText": "Pricing", "nofollow": false},
    {"page": "https://example.com/blog/launch", "anchorText": "see our plans", "nofollow": false}
  ],
  "checkedAt": "2026-09-27T12:00:00+00:00"
}
```

The **Links** table view shows the verdict, status code, final URL and source pages. Export to CSV, Excel or JSON, or fetch it through the API.

### Pricing

Pay per event: **`link-checked` = $0.0005 per unique link checked** (crawled pages count as links; each link is billed once per run, however many pages contain it). URLs skipped because of robots.txt are free.
Examples: a 10-page crawl with about 200 unique links costs about $0.10. 1,000 links cost $0.50.
Your run's *maximum cost* setting is respected: the crawl stops at what it allows.

### Tips

- Want a short report? Turn on **Only output broken or redirected links**. Every checked link is still billed; healthy ones are just hidden.
- Big site? Raise *Max pages to crawl per site* and *Max links to check*. For your own site you can lower the per-host delay.
- Schedule weekly runs and send the dataset to Slack or email with an Apify integration.

### Known limits

- HTTP only, no browser: links that exist only after JavaScript runs (single-page apps) are not seen.
- `blocked` links are not verified; check them manually if they matter.
- Some servers return 200 for missing pages ("soft 404"); these can't be detected from the status code.
- robots.txt is respected by default. Turn it off only for sites you own or are authorized to audit.

### FAQ

**Does it check links to other websites?** Yes, with one request each (no crawling of other sites). Turn off *Check external links* to skip them.

**Why is a link marked `blocked` and not `broken`?** Many large sites answer 403 or 999 to any bot. Flagging those as broken would bury your real 404s in false alarms.

**Does it collect personal data?** No. It records URLs, status codes and anchor text only. `mailto:` and `tel:` links are ignored.

**Is it polite to the sites it crawls?** Yes. It sends an identifying user agent, waits between requests to the same host, retries with exponential backoff and respects robots.txt.

Related Actors: [Bulk URL Status & Indexability Checker](https://apify.com/moha-tah/url-status-checker) (check a list of URLs you already have) · [Sitemap Extractor & Monitor](https://apify.com/moha-tah/sitemap-extractor).

# Actor input Schema

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

Start pages, one per line (usually the homepage). The crawler follows links on the same site (www and non-www count as one site).

## `maxPagesPerSite` (type: `integer`):

Pages whose links get extracted. Links found beyond this limit are still checked, just not crawled.

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

Also check links pointing to other websites (one request each, no crawling).

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

Also check <img>, <script> and stylesheet URLs, not only <a href> links.

## `onlyProblems` (type: `boolean`):

Hide healthy links from the dataset. Every checked link is still billed the same.

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

Hard cap on unique links (pages included) per run, to keep cost predictable. The run's max cost setting also caps it.

## `maxRedirects` (type: `integer`):

Redirect hops to follow before reporting the link as broken.

## `respectRobotsTxt` (type: `boolean`):

Do not fetch URLs that robots.txt disallows (they are reported, not billed). Turn off only for sites you own or are authorized to audit.

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

Requests in parallel across all hosts.

## `perHostDelayMs` (type: `integer`):

Politeness delay per host. Lower it for your own sites.

## `requestTimeoutSecs` (type: `integer`):

Per request; retries with backoff are automatic.

## Actor input object example

```json
{
  "startUrls": [
    "https://books.toscrape.com"
  ],
  "maxPagesPerSite": 10,
  "checkExternalLinks": true,
  "checkResources": false,
  "onlyProblems": false,
  "maxLinks": 5000,
  "maxRedirects": 10,
  "respectRobotsTxt": true,
  "maxConcurrency": 10,
  "perHostDelayMs": 300,
  "requestTimeoutSecs": 20
}
```

# 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://books.toscrape.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("moha-tah/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://books.toscrape.com"] }

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

```

## MCP server setup

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