youtube-transcript-api RequestBlocked or IpBlocked on a server: four fixes
youtube-transcript-api works locally and raises RequestBlocked or IpBlocked on AWS, Vercel or GCP. Why it happens, and four fixes with code and costs.
By the Scrape Everything team · · 5 min read
The pattern is always the same. Your code that uses the Python library youtube-transcript-api works on your laptop. You deploy it to AWS, Google Cloud, Azure, Vercel, Render or a VPS, and every call fails with RequestBlocked or IpBlocked. Nothing is wrong with your code. This guide explains what the error means and gives four ways out, including the cases where the free library is still the right choice.
What RequestBlocked and IpBlocked mean
The library's own README is direct about the cause: "YouTube has started blocking most IPs that are known to belong to cloud providers." It adds that a self-hosted setup can be blocked too if it sends too many requests. Both exceptions say the same thing: YouTube refused the request because of the address it came from, not because of the video. The README section on IP bans is the primary source for everything in this part.
from youtube_transcript_api import YouTubeTranscriptApi
try:
YouTubeTranscriptApi().fetch("VIDEO_ID") # the 11-character ID, not the URL
except Exception as error:
print(type(error).__name__) # RequestBlocked or IpBlocked on a blocked addressA quick test settles it: run the same script, with the same library version and the same video, from your home connection. If it works there and fails on the server, the server's IP address is the problem. Upgrading the library fixes parser breakages when YouTube changes its pages; it does not change which address your requests come from.
Fix 1: rotating residential proxies
This is the fix the library documents. Requests leave through residential addresses that YouTube does not treat as a data center. The README recommends rotating residential proxies and warns that static proxies get banned after extended use. It ships a ready-made configuration for one provider and a generic one for any other.
from youtube_transcript_api import YouTubeTranscriptApi
from youtube_transcript_api.proxies import GenericProxyConfig, WebshareProxyConfig
# A rotating residential pool from the provider the README names
ytt_api = YouTubeTranscriptApi(
proxy_config=WebshareProxyConfig(
proxy_username="<proxy-username>",
proxy_password="<proxy-password>",
)
)
# Any other provider
ytt_api = YouTubeTranscriptApi(
proxy_config=GenericProxyConfig(
http_url="http://user:pass@proxy.example.com:8000",
https_url="https://user:pass@proxy.example.com:8000",
)
)
transcript = ytt_api.fetch("VIDEO_ID")- Good for: teams that already run proxies, or that need other parts of the library such as translated transcripts.
- Cost: a proxy plan, billed monthly by traffic or by number of addresses, whether or not you use it.
- Catch: the README says it plainly: "using a proxy doesn't guarantee that you won't be blocked." You own the retries, the rotation and the monitoring.
Fix 2: fetch on the user's device
If your product has a piece that runs on the user's machine, such as a browser extension, a desktop app or a mobile app, fetch the captions there and send the text to your server. The request then comes from the user's own connection. This does not work from an ordinary web page, because browsers block cross-origin requests to YouTube, and it does not help a backend job that has no user in front of it.
Fix 3: run the job from a residential connection
For a nightly batch of a few hundred videos, a small machine on an office or home connection that pulls video IDs from a queue is enough, and it is free. Keep the request rate low: the README notes that too many requests get a self-hosted address blocked as well. This is a reasonable fix for internal tools and a poor one for anything customers wait on.
Fix 4: a hosted transcript API
A hosted API moves the blocking problem to someone whose job it is. You send a video ID over HTTPS and get the caption segments back as JSON; the provider handles blocks, retries and YouTube's changes. With the YouTube Transcript API the segments use the same three keys as the library, text, start and duration, so the swap is one function.
from __future__ import annotations
import os
import requests
API = "https://api.scrapeeverything.com/v1/youtube/transcript"
HEADERS = {"Authorization": f"Bearer {os.environ['SCRAPEEVERYTHING_API_KEY']}"}
def fetch_transcript(video_id: str, languages: list[str] | None = None) -> list[dict]:
"""Returns the same list of dicts as
YouTubeTranscriptApi().fetch(video_id).to_raw_data()."""
payload = {"id": video_id}
if languages:
payload["lang"] = languages[0]
res = requests.post(API, headers=HEADERS, json=payload, timeout=90)
body = res.json()
if not body["success"]:
raise RuntimeError(f"{body['code']}: {body['message']}")
return [
{"text": s["text"], "start": s["start"], "duration": s["duration"]}
for s in body["data"]["segments"]
]
for snippet in fetch_transcript("VIDEO_ID", ["en"]):
print(round(snippet["start"], 1), snippet["text"])The response also carries language, is_auto_generated, the list of available_languages and the whole transcript joined into one text string, which saves the join step before you send it to a language model.
What is different from the library
- One language per request. The library takes a priority list; the endpoint takes one
langcode and matches the exact code first, then the same base language (ptmatchespt-BR). Withoutlangit prefers a hand-written track in the video's language, then YouTube's default track, then automatic captions. - No machine translation. The library can ask YouTube to translate a transcript; the endpoint returns the caption tracks that exist.
- No captions is a final answer. A video without captions, or without the language you asked for, returns
404 NO_TRANSCRIPTand the message lists the available codes. Store that result and do not retry it. - Age-restricted videos fail in both. They need a logged-in account. The README says cookie authentication is currently unavailable in the library, and the endpoint returns
AGE_RESTRICTED, a definitive 404 that is billed likeNO_TRANSCRIPT.
Which fix to choose
| Your situation | Fix |
|---|---|
| A few transcripts a day, run from your own machine | Keep the library as it is. It is free and it works from a residential address. |
| A batch job with no deadline | Fix 3: run it from a residential connection, slowly. |
| An extension, desktop or mobile app | Fix 2: fetch on the user's device. |
| A backend in the cloud, and you already operate proxies | Fix 1: rotating residential proxies. |
| A backend in the cloud, and transcripts are a feature, not your product | Fix 4: a hosted API, so a blocked address is no longer your incident. |
What the hosted route costs
On Scrape Everything a transcript costs 1 credit. New accounts get 100 free credits, which is 100 transcripts with no card. After that, credits come in one-time packs that never expire: the Builder pack is 25,000 credits for $19.99, or $0.80 per 1,000 transcripts, and larger packs lower that to $0.50. Blocks, timeouts and errors on our side are refunded automatically, a definitive answer such as 404 NO_TRANSCRIPT is billed, and a repeat request for the same video within your cache_days window costs nothing. Current numbers are on the pricing page.
FAQ
Does upgrading youtube-transcript-api fix RequestBlocked?
Not when the cause is the IP address. If the same version works from your laptop and fails on the server, an upgrade will not change the outcome. Upgrade anyway if you are several versions behind, because older releases break when YouTube changes its pages.
Why does it fail on Vercel, Lambda or Cloud Run in particular?
Serverless platforms send requests from address ranges that belong to large cloud providers, and those are the ranges the README says YouTube blocks. A different region usually lands in another blocked range.
Will cookies or logging in help?
No. The README states that cookie based authentication is currently broken in the library, and logging a personal Google account into a server job risks that account.
Can I still get automatic captions?
Yes. Both the library and the endpoint return YouTube's automatic captions when no hand-written track exists, and both tell you which kind you received.
Is it allowed to fetch YouTube transcripts?
Captions are public to anyone who opens the video, but the text belongs to the creator, so what you do with it matters more than how you fetched it. Our overview of the legal side covers the questions to ask.
Next steps
- Run your blocked video in the live example on the endpoint page, no signup needed.
- Read the longer YouTube transcript API guide for Node.js, whole channels and caption quality.
- Compare hosted options in Best YouTube transcript APIs in 2026.