DEV Community

Yusuf Yildiz
Yusuf Yildiz

Posted on Originally published at ytdlp.org

yt-dlp works on my laptop but 403s in GitHub Actions

I had a workflow that pulls metadata off a handful of YouTube URLs on a schedule. It ran fine for weeks, then started failing with Sign in to confirm you're not a bot and HTTP Error 403. The command hadn't changed, and it still worked on my laptop. It only failed in the runner.

It took me a while to accept that the command was fine and the problem was where it ran. GitHub-hosted runners share a pool of datacenter IPs (Azure), and YouTube treats those IPs as suspicious. So the same yt-dlp line that works at home gets challenged in CI, because home is a residential IP and the runner isn't.

The first thing worth doing is confirming that, so you don't spend an afternoon rewriting a command that was never broken. Run the exact line from the job on your own machine:

yt-dlp --skip-download --print "%(title)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"
# -> Me at the zoo
Enter fullscreen mode Exit fullscreen mode

If that prints the title locally and only the runner fails, the command is fine and the IP is the problem.

Two other things break CI jobs before the IP even comes into it, and they're worth fixing either way:

  • A stale yt-dlp. YouTube changes often and yt-dlp ships fixes just as often, so a version you pinned a few months ago will fail on its own. Install a fresh one every run instead of pinning.
  • A missing JavaScript runtime. yt-dlp uses one to solve YouTube's player challenges, and a bare runner doesn't have the one it looks for. Installing Deno in the job clears up a class of extraction errors that look like blocks but aren't.

Get those two right and some of your runs will start working. I want to be honest about the ceiling though: on heavily shared runner IPs, even a correct setup gets challenged intermittently, and there's no flag that makes a flagged datacenter IP look residential. The fixes that actually hold are egress that isn't a flagged datacenter IP, feeding in fresh cookies, or doing the download somewhere other than the runner. I wrote up a working workflow and where it stops working here: https://ytdlp.org/guides/yt-dlp-github-actions

If you landed here because a scheduled job keeps breaking and you'd rather not keep babysitting it, that's the itch I built importly.io to scratch - it's my own tool, so take it as that. You hand it a URL and get the file, transcript or metadata back, and it behaves the same from a GitHub Action or an agent sandbox as it does from your laptop. There's $3 of free credit and no card, which is enough to see whether it fixes your case.

But if you just want yt-dlp itself to behave in CI, the fresh-install plus JS-runtime setup in that guide is where I'd start.

Top comments (0)