Embedded YouTube video shows Video unavailable (Error 153) in a Flutter app
Video unavailableShort answer
Error 153 means the embedded player got no HTTP Referer header or other client identification. A WebView sends an empty Referer by default, so set one that is an https URL of your app ID. On Flutter web, do not suppress the Referer. Errors 101 and 150 are different: the owner blocks embedding.
Fix it fast
1Find out which cause you have
Note the exact error code on the player. 153 is about your app's request. 100, 101 and 150 are about the video itself.
flutter run -v2Match what you see, then jump to its fix
- 1
Error 153 on Android or iOS, while the same video plays in a desktop browserThe player runs in a WebView that sends no RefererFix - 2
Error 153 only in the web buildFlutter web: the page suppresses the RefererFix - 3
Error 101 or 150 (or 100 for a removed or private video)The video owner does not allow embeddingFix
- 1
What does the error look like?
Video unavailableError 153Error 101
Cause 1 of 3
The player runs in a WebView that sends no Referer
1Check
WebViews and apps send an empty Referer by default. YouTube requires embedded clients to identify themselves through the HTTP Referer header.
flutter pub deps | grep -i "webview\|youtube"2Fix
Set the Referer yourself. It should be a fully qualified https URL whose domain is your app ID, in reverse-DNS form such as the package name, and it should stay stable across app versions. On Android the documented routes are the baseUrl of loadDataWithBaseURL or a Referer header on loadUrl. On iOS they are loadHTMLString with a baseURL or a Referer header on loadRequest. Check your player package for the matching option.
# Example Referer for an app with the id com.example.myapp
https://com.example.myapp3Verify
Reload the screen. The player starts instead of showing the error.
flutter runConfirmed by developers.google.com
Cause 2 of 3
Flutter web: the page suppresses the Referer
1Check
A Referrer-Policy that removes the Referer, or links opened with noreferrer, strips the client identity. YouTube recommends strict-origin-when-cross-origin.
curl -sI https://example.com | grep -i referrer-policy2Fix
Send the recommended policy as a response header from the server that hosts the Flutter web app, and do not open the video link with noreferrer.
# response header to send with the Flutter web files
Referrer-Policy: strict-origin-when-cross-origin3Verify
Reload the page and check that the response carries the header.
curl -sI https://example.com | grep -i referrer-policyConfirmed by developers.google.com
Cause 3 of 3
The video owner does not allow embedding
1Check
101 and 150 mean the owner does not allow playback in embedded players. 100 means the video was removed or is private.
# open the video on youtube.com and look for an embed or privacy restriction2Fix
Use a video that allows embedding, or ask the owner to allow it.
# no code change: use another video ID3Verify
The new video plays in the player.
flutter runConfirmed by developers.google.com
How do I stop it coming back?
- Test the player on a real device and in a release build, not only in a desktop browser.
- Keep one stable app ID and use it for the Referer in every release.
- Add the origin parameter to the embed URL, as the IFrame API reference recommends.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
Related fixes
Mobile apps
AudioCache has no play method after updating audioplayers
The method 'play' isn't defined for the type 'AudioCache'.
Since audioplayers 1.0, AudioCache only turns asset files into local files and caches them.
2 causes, each with a fixMobile apps
Flutter Bloc throws that emit was called after the event handler completed
emit was called after an event handler completed normally.
Each on<Event> handler gets its own Emitter, and it stops working the moment the handler's returned Future completes.
2 causes, each with a fixMobile apps
analysis_options.yaml: the URI it includes can't be found
include_file_not_found
The analyzer reports include_file_not_found when the file named after include: in analysis_options.yaml does not resolve.
2 causes, each with a fixMobile apps
Dart error: the body might complete normally and return null for a non-nullable type
body_might_complete_normally
Dart found a path through your function or callback that reaches the closing brace without a return.
3 causes, each with a fixMobile apps
Dart throws ConcurrentModificationError while looping over a list
ConcurrentModificationError
Dart throws this when a collection changes size while something iterates it.
2 causes, each with a fixMobile apps
Dart cannot turn a compact timestamp like 20201101153000 into a DateTime
FormatException: Invalid date format
DateTime.parse accepts a subset of ISO 8601, and a time part must be introduced by T or a space.
2 causes, each with a fix