yt-dlp: [Youtube] Immediate HTTP Error 403 on download

🚨 click here to see the current status of this issue 🚨

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Region

Germany

Provide a description that is worded well enough to be understood

Downloading videos currently results in an 403 error. What I found out is, that the video gets played in browser when being logged in, when trying to start the videos in a private window without cookies, the video doesn’t start without an error. However, the ads do play.

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

yt-dlp -vU https://www.youtube.com/watch?v=l35ok-7n2IU
[debug] Command-line config: ['-vU', 'https://www.youtube.com/watch?v=l35ok-7n2IU']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2024.12.15.232913 from yt-dlp/yt-dlp-nightly-builds [d298693b1] (win_exe)
[debug] Python 3.10.11 (CPython AMD64 64bit) - Windows-10-10.0.19045-SP0 (OpenSSL 1.1.1t  7 Feb 2023)
[debug] exe versions: ffmpeg 2024-05-13-git-37db0454e4-essentials_build-www.gyan.dev (setts), ffprobe 2024-05-13-git-37db0454e4-essentials_build-www.gyan.dev, phantomjs 2.1.1
[debug] Optional libraries: Cryptodome-3.21.0, brotli-1.1.0, certifi-2024.12.14, curl_cffi-0.5.10, mutagen-1.47.0, requests-2.32.3, sqlite3-3.40.1, urllib3-2.2.3, websockets-14.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets, curl_cffi
[debug] Loaded 1837 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Latest version: nightly@2024.12.15.232913 from yt-dlp/yt-dlp-nightly-builds
yt-dlp is up to date (nightly@2024.12.15.232913 from yt-dlp/yt-dlp-nightly-builds)
[youtube] Extracting URL: https://www.youtube.com/watch?v=l35ok-7n2IU
[youtube] l35ok-7n2IU: Downloading webpage
[youtube] l35ok-7n2IU: Downloading ios player API JSON
[youtube] l35ok-7n2IU: Downloading mweb player API JSON
[debug] [youtube] Extracting signature function js_03dbdfab_107
[debug] Loading youtube-sigfuncs.js_03dbdfab_107 from cache
[debug] Loading youtube-nsig.03dbdfab from cache
[debug] [youtube] Decrypted nsig aV2SlxDn5CNaYgrXF => IlSumDx_jM-HcQ
[debug] Loading youtube-nsig.03dbdfab from cache
[debug] [youtube] Decrypted nsig DD96eHcKsL6Qq9E90 => hxviA3B9kS_9QA
[debug] [youtube] Extracting signature function js_03dbdfab_103
[debug] Loading youtube-sigfuncs.js_03dbdfab_103 from cache
[youtube] l35ok-7n2IU: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec, channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] l35ok-7n2IU: Downloading 1 format(s): 313+251
[debug] Invoking http downloader on "https://rr3---sn-8vq54voxqx-cxgs.googlevideo.com/videoplayback?expire=1734837482&ei=ijBnZ5bkLN7t6dsPxZnjqA8&ip=2a02%3A8109%3A9d8f%3A3e00%3A693d%3A9ea1%3A7054%3A8015&id=o-AD-6zsiRz7FIC1te5s18LyYs5Y8ksIOFcZIi9DwV-4eZ&itag=313&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&met=1734815882%2C&mh=OR&mm=31%2C29&mn=sn-8vq54voxqx-cxgs%2Csn-i5h7lnll&ms=au%2Crdu&mv=m&mvi=3&pl=43&rms=au%2Cau&initcwndbps=3333750&bui=AfMhrI_ngaE8pa7Haos9jOTZ3q5auYyyVfDQXr5jsroWyEFRCr9GmkX8qUqEH8wbn8V2hlhS9c3-WuEV&spc=x-caUMh6H49vmv_2Nq1W3Z-hU6SkreEU_haD9Rl720YYO1YqHc5O&vprv=1&svpuc=1&mime=video%2Fwebm&rqh=1&gir=yes&clen=6804056254&dur=3879.720&lmt=1734697485233688&mt=1734815349&fvip=3&keepalive=yes&fexp=51326932%2C51335594%2C51371294&c=IOS&txp=4432434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&sig=AJfQdSswRgIhAPI4tNsuKx7xFM9mNgrxyyp8hSGN0-5CbzTuHZVdC9jXAiEA8wF4h9cuQjRMIDaEFCRCiwLDkWelVq5pslq_8uHVYPg%3D&lsparams=met%2Cmh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Crms%2Cinitcwndbps&lsig=AGluJ3MwRgIhAJJ-X3tKgTINiH5L18EpIN5fb92EiSjLW5srWP1fl6CmAiEAncDu51bsexappSLmrSkwFZ4ZUfKzdhk4uOfkHq8jU8Q%3D"
ERROR: unable to download video data: HTTP Error 403: Forbidden
Traceback (most recent call last):
  File "yt_dlp\YoutubeDL.py", line 3461, in process_info
  File "yt_dlp\YoutubeDL.py", line 3199, in dl
  File "yt_dlp\downloader\common.py", line 464, in download
  File "yt_dlp\downloader\http.py", line 367, in real_download
  File "yt_dlp\downloader\http.py", line 118, in establish_connection
  File "yt_dlp\YoutubeDL.py", line 4162, in urlopen
  File "yt_dlp\networking\common.py", line 117, in send
  File "yt_dlp\networking\_helper.py", line 208, in wrapper
  File "yt_dlp\networking\common.py", line 340, in send
  File "yt_dlp\networking\_requests.py", line 365, in _send
yt_dlp.networking.exceptions.HTTPError: HTTP Error 403: Forbidden

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 28
  • Comments: 87 (19 by maintainers)

Commits related to this issue

Most upvoted comments

A workaround I found is to force IPv4, I decided to try after it worked on my laptop and not my desktop. They are either having issues or intentionally banning v6 addresses that are downloading a lot.

Basically, just pass the -4 flag and if it still doesn’t work try the -6 flag. If neither work, then you may be SoL in terms of youtube.

An update from some preliminary investigation - there are two issues we appear to be seeing here:

  1. A rollout or A/B test of what we presume is a PO Token requirement on the iOS client. This will produce an HTTP 403 error on iOS videoplayback urls, either immediately or midway through streaming if a valid iOS PO Token is not provided.

    • You can test if this is the issue by trying HLS formats (-S proto:hls) or use another client (--extractor-args "youtube:player-client=default,-ios"). Both should work.
    • A fix has been merged and released that skips these iOS formats that require a PO Token. HLS formats do not appear to be impacted yet.
  2. YouTube is experimenting with some sort of new aggressive IP-based block on videoplayback urls - perhaps to replace or complement the existing “sign in to confirm you are not a bot” error on the player endpoint. This produces an HTTP 403 error on videoplayback urls, regardless of client and protocol (HTTPS, DASH, HLS, UMP, SABR, ONESIE).

    • If you are seeing this for the first time, backing off further downloading/requests for a little while may help to lift it. It is recommended to make use of the yt-dlp sleep options to help avoid it.
    • Otherwise, you might need to change IP.
    • Update: this comment for more details.

With the changes YouTube has been pushing recently, it is likely the out-of-the-box YouTube format support for yt-dlp will become more limited. To retain format support, we recommend looking into using/adding the WEB client with a PO Token. You can do this manually or automatically via plugins. Refer to the PO Token Guide for more information.

Whenever i download a video from Y2Mate this stupid “Access denied” error keeps popping up!

Adding --extractor-args “youtube:po_token=web+XXX” fixed it for me. I have also passed the user agent, switched to ipv4 and downloaded a nightly build, but this is the only thing that worked

Refreshing my public IP to another worked for me, looks like YT are detecting the download and banning via IP.

Not sure how much it helps, but NewPipe have a fix for this - they implement YT’s poToken generator in a mini Javascript VM that’s able to pass YT’s integrity checks: https://github.com/TeamNewPipe/NewPipe/pull/11955

I can confirm that downloading works in the NewPipe client.

@richardstevenhack

BTW, thanks for your suggested workaround above. I just got it working now.

Here are the full steps, formatted slightly, to make it easier for others to copy-paste and get going, if they are using the Terminal.app on macOS.

Cookie Workaround for HTTP 403 Error

  1. Before you begin, open System Preferences > Security & Privacy then grant “Full Disk Access” to Terminal.app[^1].

    If you haven’t granted Terminal.app this permission, you will get the following error when executing the command in step 2:

    PermissionError: [Errno 1] Operation not permitted: '/Users/<user>/Library/Cookies/Cookies.binarycookies'
    
  2. The next command will extract ALL your browser cookies into the file cookies.txt.

    # Run 1, 2 or 3 depending on which browser you are using 
    
    # 1. Google Chrome
    yt-dlp -vU --cookies-from-browser chrome --cookies cookies.txt
    
    # 2. Mozilla Firefox
    yt-dlp -vU --cookies-from-browser firefox --cookies cookies.txt
    
    # 3. Apple Safari
    yt-dlp -vU --cookies-from-browser safari --cookies cookies.txt
    

    Note that the argument -v enables verbose output while the argument -U updates your version of yt-dlp to the latest.

  3. Now proceed with downloading your videos as before, but remember to include the cookies.txt created in step 2:

    yt-dlp -v --cookies youtube-cookies.txt "https://www.youtube.com/watch?v=<video-id>"
    

[^1]: The fix is from this comment https://github.com/yt-dlp/yt-dlp/issues/7392#issuecomment-1657496651 or you can refer to the screenshot in this SO answer, if the explanation is unclear.

@coletdjnz … saw you removed “high priority” (which I would disagree with 😃 and just to be clear; The issue persists and has not been resolved. I can’t use the tool without risking to have my IP banned again, unless I login and used an account … which, in my use-case, completely defeats the purpose of using the tool in the first place… (privacy).

Hope this issue isn’t forgotten as a result …

The cookies option is to log in to your Youtube account, then execute yt-dlp with this option:

yt-dlp --cookies-from-browser [browser: chrome or firefox or whatever] --cookies cookies.txt. yt-dlp will extract the browser cookies and save them to the filepath specified after --cookies.

Then you pass the cookies from the cookies.txt file to yt-dlp with your download request using this option:

–cookies /path/to/cookies/file.txt

I’m not sure if you have to be logged in to the account while passing the cookies.txt file. I haven’t tried that.

I applied the TLSv1_3 fix, same 403 error

wassim@jupiter:~/dev/yt-dlp$ python3 -m yt_dlp --verbose -f 140 https://www.youtube.com/watch?v=20eebO8zBYk
[debug] Command-line config: ['--verbose', '-f', '140', 'https://www.youtube.com/watch?v=20eebO8zBYk']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.12.23 from yt-dlp/yt-dlp [65cf46cdd] (source)
[debug] Lazy loading extractors is disabled
[debug] Git HEAD: 0b6b7742c
[debug] Python 3.12.7 (CPython x86_64 64bit) - Linux-6.11.0-13-generic-x86_64-with-glibc2.40 (OpenSSL 3.3.1 4 Jun 2024, glibc 2.40)
[debug] exe versions: ffmpeg 7.0.2 (setts), ffprobe 7.0.2
[debug] Optional libraries: certifi-2024.06.02, requests-2.32.3, secretstorage-3.3.3, sqlite3-3.46.1, urllib3-2.0.7

Since today, youtube is blocking video viewing without ads. It impacts yt-dlp but also firefox + ublock origin. Everything works fine on chrome.

I started seeing this yesterday, so quite some time after this was first seen. My findings:

  • Started getting 403 Forbidden yesterday.
  • Tested various browsers, Ungoogled-Chromium, Brave, Firefox, Zen, no difference and can only play ads.
  • In the browser, seems to be the videoplayback call that fails.
    • Ungoogled-Chromium status: (failed)net::ERR_INCOMPLETE_CHUNKED_ENCODING or (failed)net::ERR_EMPTY_RESPONSE
    • Firefox status: NS_ERROR_NET_INTERRUPT, CORS Failed, or NS_ERROR_PARTIAL_TRANSFER
  • yt-dlp -4 or -6 makes no difference.

What works:

  • Browser where you’re logged in to an YT account which kind of defeats my purpose of using yt-dlp, privacy.

Good morning everyone! Just want to add my findings, maybe it helps:

  • I usually download with a dedicated youtube-vm on my homeserver, but not the last two days.
  • Got 403 immediately this morning. Since none of the command line parameters posted here helped, I assume an IP-ban.
  • IPv4/IPv6 both 403 on the vm.
  • Reconnected and got a new IPv4 and a new IPv6 prefix. No change.
  • Tried downloading on my workstation instead and it worked. IPv4, IPv6-prefix and yt-dlp version are the same as on the vm.

The only difference, seen from outside my network, is that I visited YouTube on my workstation before starting the yt-dlp download (of course, to gather the links). Firefox with logged in account. And the vm is on another IPv6 subnet (VLAN).

I wish you all merry christmas and some relaxing days, even without YouTube! 🎄

I also faced HTTP error 403 too while using ytdlp-interface which relies on yt-dlp. yt-dlp version is latest. Not just yt-dlp, 3rd-party YouTube downloaders (Tried Wonderfox & Winxvideo) also affected. Changing DNS makes YouTube downloader working again (I use Cloudflare DNS).

@InfinityLoop1308 I was trying to see if reports of the ios PO token requirement were getting mixed in with the overall googleplayback IP block that seems to be going on in the most of the reports

@InfinityLoop1308 as stated in an earlier comment, this issue looks like it is two separate issues being reported in the same thread. I am not suggesting that using mweb is a viable workaround for everybody. I am trying to figure out what is going on.

@bashonly it works if I remove the cookies from my config, yes. Also I just ran “update-to nightly” so it should be the latest possible version

@bashonly I can successfully download with that mweb argument instead of the PO token, with 2024.12.13.

@Husenberg @vphantom could each of you test if --extractor-arg "youtube:player_client=mweb" works (without any PO token or cookies)? Also please make sure you are on yt-dlp version 2024.12.13 or later

It’s possible that we are seeing multiple issues with the same error being reported in this thread, and this will help diagnose exactly what is happening.

I can confirm: I made a PO token with instructions in https://github.com/yt-dlp/yt-dlp/wiki/Extractors#manually-acquiring-a-po-token-from-a-browser-for-use-when-logged-out without the --cookies bit, just the --extractor-args argument formated as @Husenberg did above and from the same IP address at least, downloading does work. Not sure how long it’ll last but even doing this once a day seems tolerable in order to get durable local files.

Thanks for the tip!

For anyone on a data center IP, this is to be expected and there’s nothing we can do about it.

But I have a question for anyone on a residential IP who is experiencing this issue:

What were your downloading habits like before you started getting the 403 errors? Were you downloading in bulk, e.g. large playlists/channels/batches? Concurrent downloads? Or did you just go to download a single video and got hit with the 403?

Update: We have enough information on this for now, thanks. Please do not post further comments on this.

I get this too, and have had it for a few hours. If I try to play the video in a browser, it just loops adverts constantly, or sometimes there’s a black window with spinner. Seems to be a bug on the youtube side. Also using yt-dlp updated from the master branch today.

Edit: Forcing IPv4 (-4 option) has worked for me today.