youtube-transcript-api errors
youtube-transcript-api errors and how to fix them
Every exception the youtube-transcript-api Python library raises, what each one means, and the fix, from IP blocks on cloud servers to missing captions.
Running this on a server? TranscriptFetch returns the same transcript from any IP, no proxies. Try it free →
youtube-transcript-api is the most widely used Python library for YouTube transcripts. When it cannot return a transcript it raises a specific exception, and the exception name tells you whether the problem is your code, the video, or where your code runs.
Written against version 1.2.4 of the library. The exception names and messages below are copied from its source.
Find your error
| Exception | What it means |
|---|---|
RequestBlocked | YouTube is refusing requests from your IP: usually a cloud server or too many requests. |
IpBlocked | The same block, detected as an HTTP 429 or a CAPTCHA page. |
TranscriptsDisabled | Subtitles are disabled for this video. |
NoTranscriptFound | The video has transcripts, but none in the language codes you asked for. |
VideoUnavailable | The video is no longer available: removed, private, or the ID is wrong. |
InvalidVideoId | You passed a URL where the library expects a video ID. |
AgeRestricted | The video is age-restricted, and the library cannot fetch it without signing in. |
PoTokenRequired | YouTube asked for a proof-of-origin token the library cannot provide. |
VideoUnplayable | YouTube reports the video as unplayable, with a reason (region lock, members only and similar). |
YouTubeRequestFailed | The HTTP request to YouTube itself failed; the message carries the reason. |
NotTranslatable | The transcript you picked cannot be translated. |
TranslationLanguageNotAvailable | The translation language you asked for is not offered. |
FailedToCreateConsentCookie | The library could not accept YouTube's cookie consent page (common on EU servers). |
YouTubeDataUnparsable | YouTube's response changed shape; usually fixed by upgrading the library. |
CookieError, CookiePathInvalid, CookieInvalid | Problems loading the cookie file used to sign in. |
TooManyRequests | Versions before 1.0: the same IP block, now raised as IpBlocked. |
Errors about where your code runs
RequestBlocked, IpBlocked and PoTokenRequired say nothing about your code. They appear when YouTube decides the request looks automated: almost always on cloud servers (AWS, Google Cloud, Azure and most hosting), or after many requests from one IP. The same script usually works on a laptop. How to fix RequestBlocked and IpBlocked.
Catching them
Every exception above except the cookie errors inherits from CouldNotRetrieveTranscript, so one except covers them:
from youtube_transcript_api import (
CouldNotRetrieveTranscript,
RequestBlocked,
YouTubeTranscriptApi,
)
try:
transcript = YouTubeTranscriptApi().fetch(video_id)
except RequestBlocked:
... # where you run: see the RequestBlocked page
except CouldNotRetrieveTranscript as e:
print(type(e).__name__, e) # about the video itselfCatch RequestBlocked before CouldNotRetrieveTranscript: it is the one you can do something about, and IpBlocked is a subclass of it.
When the library is not enough
The library reads YouTube directly from wherever your code runs, which is why server deployments hit IP blocks. TranscriptFetch is a hosted API (our product) that fetches from its own network, so the same request works from any server. It returns the transcript as text and timestamped segments, also covers TikTok and Instagram, and transcribes the audio with AI when a video has no captions. 50 free credits a month, no card.
Need transcripts that work from a server?
TranscriptFetch fetches YouTube, TikTok and Instagram transcripts from its own network, with AI transcription when a video has no captions. Free credits every month, no card.