# YouTube captions work locally but fail on Netlify, Vercel or AWS

> Transcript code that works on your laptop raises RequestBlocked or a bot check once deployed. How to tell which failure you have, and which routes are open to you.

Source: https://cozybit.dev/guides/youtube-captions-blocked-on-cloud-hosts/

Guide

Your transcript code runs fine on your laptop. Once deployed, it raises `RequestBlocked`, or YouTube answers "Sign in to confirm you're not a bot". This guide shows how to tell which failure you have and which routes are open to you.

Updated 2 December 2026. Written by Cozybit, which makes one of the options below.

In short

- **Same error locally:** the video has no captions (in that language). Diagnose
- **Only on the host:** YouTube refuses your host's IP range.
- **Function ended without a library error:** a timeout.
- **Routes:** run locally or paste, the official Data API for videos you may edit, a hosted transcript service, or our actor on Apify. Compare
- **To try ours:** an Apify account and token; videos without captions and errors are free. API example

## 1. Find out which failure you have

Three different problems end up looking alike in a deployment log. Before changing anything, try the same video ID locally, log the exception's class name (not just its message), and note how long the call ran before it failed.

**Transcript code fails once deployed** Run the same video ID on your own machine, and note the exception class and how long the call ran.

1. Same error locally**No captions** `TranscriptsDisabled` or `NoTranscriptFound`: no hosting change helps.
2. Works locally, fails on the host**Host refused** `RequestBlocked`, HTTP 403 or 429, or a bot check.
3. The function ended without a library error**Timeout** The platform's time limit came first: fewer videos per call.

Three failures that look alike in a deployment log, told apart by two checks.

| Failure | What you see | What it means |
|---|---|---|
| **No captions** | `TranscriptsDisabled` or `NoTranscriptFound` in `youtube-transcript-api`; the same error locally | The video has no captions, or none in the language you asked for. No hosting change helps. Ask for another language, or use speech-to-text, which is a different job. |
| **Host refused** | `RequestBlocked` or `IpBlocked`, HTTP 403 or 429, or "Sign in to confirm you're not a bot"; the same video works locally | YouTube declines requests from your host's IP range. The library's README says YouTube blocks "most IPs that are known to belong to cloud providers". Retrying from the same host rarely changes the answer. |
| **Timeout** | The platform ends the function, for example Vercel's `FUNCTION_INVOCATION_TIMEOUT` (HTTP 504) or Lambda's `Task timed out after 3.00 seconds`, with no exception from the library | The work did not finish within your function's time limit: long videos, many videos in one call, or slow answers. Process fewer videos per call, or start a job and collect the result later. |

## 2. Routes that fit

For a refused host, these are the options that keep you within YouTube's official channels or someone else's maintained service.

### Run it where it works, or paste it

For one-off videos, fetch the transcript on your own machine, or copy it from YouTube's "Show transcript" panel. Fine for a handful of videos; it does not run unattended.

### The official YouTube Data API

`captions.list` and `captions.download` need OAuth, and `captions.download` works only for videos you have permission to edit. This is the right route for your own channel, not for other people's videos.

### Hosted transcript services

Several companies run transcript APIs, usually sold as prepaid credits or monthly plans. When comparing, check what they charge for videos without captions or for failed requests, whether they publish reliability figures, and their terms.

### Our actor on Apify Ours

[YouTube Transcript Scraper](https://cozybit.dev/tools/youtube-transcripts/) runs on Apify's platform and returns one record per video. Each record has a `status` (`ok`, `no_captions` or `error` with an `error_code`), so the failure types above stay separate in your data. It reads only captions YouTube shows publicly and never signs in.

The `youtube-transcript-api` README also documents proxy configuration. That brings its own cost, upkeep and terms questions, and this guide doesn't recommend it as a default fix.

## 3. Calling the actor

You need an Apify account and API token (Console, *Settings, API & Integrations*). The free plan needs no card and returns up to 20 videos per run.

**A few videos per call (token in APIFY_TOKEN)**

```bash
curl -sS --max-time 310 -X POST \
  "https://api.apify.com/v2/acts/mzceZowBx7VrobetK/run-sync-get-dataset-items?maxTotalChargeUsd=0.10" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"], "languages": ["en"], "includeSegments": false}'
```

The response is a JSON array with one record per video (sample below).

- `run-sync-get-dataset-items` waits at most 300 seconds, then answers HTTP 408. Serverless functions usually stop sooner, so keep synchronous calls to a few videos and use an asynchronous run for batches.
- `maxTotalChargeUsd` caps what one run may charge; the actor stops cleanly when it is reached.
- Don't retry a timed-out POST automatically; check your runs in Console before retrying.
- Send the token in the `Authorization` header, never as `?token=` in the URL, where it ends up in logs.

**Node 18+, for example in a Vercel or Netlify function**

```javascript
const res = await fetch(
  'https://api.apify.com/v2/acts/mzceZowBx7VrobetK/run-sync-get-dataset-items?maxTotalChargeUsd=0.10',
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.APIFY_TOKEN}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      urls: [videoUrl],
      languages: ['en'],
      includeSegments: false,
    }),
  },
);
if (!res.ok) throw new Error(`Apify answered HTTP ${res.status}`);
const [video] = await res.json();
if (video.status === 'ok') console.log(video.text);
else console.log(video.status, video.error_code, video.error);
```

**Batches: start a run, wait, then read the records**

```bash
# 1. Start a run; the answer comes back at once
curl -sS -X POST "https://api.apify.com/v2/acts/mzceZowBx7VrobetK/runs?maxTotalChargeUsd=1" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d @input.json
# The answer's data.id is RUN_ID and data.defaultDatasetId is DATASET_ID.

# 2. Wait up to 60 s per call until data.status is SUCCEEDED
curl -sS "https://api.apify.com/v2/actor-runs/RUN_ID?waitForFinish=60" \
  -H "Authorization: Bearer $APIFY_TOKEN"

# 3. Read the records as JSON, CSV or Excel (format=json, csv or xlsx)
curl -sS "https://api.apify.com/v2/datasets/DATASET_ID/items?format=csv" \
  -H "Authorization: Bearer $APIFY_TOKEN" -o results.csv
```

**AI agents: Apify's MCP server with only this actor as a tool**

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com?tools=cozybit/youtube-transcript-scraper"
    }
  }
}
```

## 4. Sample output

With `"includeSegments": true` each `ok` record also gets a `segments` list with `start`, `duration` and `text`.

**Example record**

```json
[
  {
    "video_id": "EXAMPLE0001",
    "url": "https://www.youtube.com/watch?v=EXAMPLE0001",
    "source_url": null,
    "status": "ok",
    "error_code": null,
    "error": null,
    "title": "Example talk",
    "channel_name": "Example Channel",
    "channel_id": "UCexample000000000000000",
    "view_count": 18420,
    "published_at": "2026-01-15T09:00:00-08:00",
    "duration_seconds": 95,
    "language": "en",
    "language_name": "English",
    "is_auto_generated": true,
    "available_languages": [
      {
        "code": "en",
        "name": "English",
        "is_auto_generated": true
      }
    ],
    "segment_count": 2,
    "text": "This is invented example text. It stands in for the video's captions.",
    "subtitles": null,
    "scraped_at": "2026-12-02T12:00:00.000Z"
  }
]
```

A video without captions comes back with `"status": "no_captions"`; other failures with `"status": "error"` and an `error_code` such as `video_unavailable`, `age_restricted` or `bot_check`, plus a readable `error` message. Their transcript fields are then empty or `null`.

Transcripts belong to their rights holders, usually the video's creator. Check that your use is permitted and get permission where it is needed.

## 5. Price and limits

- You pay per delivered transcript, with platform costs (proxies and compute) included. See the current price on the [Store page](https://apify.com/cozybit/youtube-transcript-scraper/pricing): a trial price until 31 Dec 2026.
- Videos without captions and errors are free.
- An Apify account and token are required. The free plan has no card and a limit of 20 videos per run.
- Age-restricted and members-only videos return an error, because the actor never signs in. It does no speech-to-text and no translation.
- YouTube has no official public transcript API for other people's videos, so a change on YouTube's side can break the actor until it is updated.

## 6. Reliability

404 / 407 videos returned a transcript

404 of 407 videos returned a transcript. The other three got the right answer: 2 videos without captions and 1 private video. These figures come from 44 runs on the Apify platform on 30 and 31 October 2026, with videos in six languages, manual and automatic captions, Shorts, podcasts of up to 5 hours and channel links.

Problems and questions: the actor's Issues tab on Apify.

Our tool for this

YouTube Transcript Scraper

Captions as plain text, timestamped segments and SRT or WebVTT files.

[Try it in Apify Console](https://apify.com/cozybit/youtube-transcript-scraper) [Tool page](https://cozybit.dev/tools/youtube-transcripts/)
