ytdlp.org
On this page

Troubleshooting guide

How to use cookies with yt-dlp

If yt-dlp can find a page but fails on the actual media, cookies are often the missing piece. In plain English: you are letting yt-dlp reuse the signed-in session from your browser so it can access content that is not available to an anonymous request.

Short answer: On your own machine, pass cookies with --cookies-from-browser chrome or a cookies.txt file. On a server there is no browser to read from, so you keep a cookie file alive as a secret and re-export it when it goes stale (below). If downloads have to keep working inside an app, a hosted API such as Importly takes the link and returns the file, transcript or metadata, and it works from servers where self-hosted downloads get blocked, with nothing to install or patch on the box.

Quick answer

Start with browser extraction. It is the fastest and cleanest option when you are already logged in.

yt-dlp --cookies-from-browser chrome "URL"

Replace chrome with the browser you actually use, like firefox, edge, or brave when supported.

When cookies are needed

  • the site says sign in is required
  • the media is age-gated or region-gated
  • private or semi-private content works in your browser but not in yt-dlp
  • the extractor says cookies are required or the request returns 403/401 style failures

If the page truly requires a logged-in session, updating yt-dlp alone will not fix it. You need to pass session state in a way yt-dlp can use.

Use browser cookies first

yt-dlp --cookies-from-browser chrome "URL"
yt-dlp --cookies-from-browser firefox "URL"

This is usually better than exporting a file manually because it avoids one more stale artifact in your workflow. If it works, use it and move on.

Pick the right browser and profile

The browser name is only the first part of the flag. The full form lets you point yt-dlp at a specific profile, a Linux keyring, or a Firefox container:

--cookies-from-browser BROWSER[+KEYRING][:PROFILE][::CONTAINER]

Supported browsers today are brave, chrome, chromium, edge, firefox, opera, safari, vivaldi and whale. If you do not name a profile, yt-dlp uses the most recently accessed one - which is the usual reason extraction pulls the wrong cookies when you keep more than one profile.

If the cookies you need live in a different profile - a work profile, a second signed-in account - name it explicitly:

yt-dlp --cookies-from-browser "chrome:Profile 1" "URL"
yt-dlp --cookies-from-browser "firefox:dev-edition-default" "URL"

On Linux, Chromium-family cookies are encrypted with the desktop keyring, so if extraction comes back empty, name the keyring with a +: chrome+gnomekeyring, or chrome+kwallet6 on KDE (basictext, kwallet and kwallet5 are also supported).

Two platform gotchas worth knowing. On macOS, Safari keeps its cookies in a protected location, so the terminal you run yt-dlp from needs Full Disk Access (System Settings → Privacy & Security → Full Disk Access). And with Chrome, close the browser completely before extracting - a running Chrome locks the cookie database, and recent versions encrypt it in a way yt-dlp cannot always read, which is why Firefox or a cookies.txt file is often the more dependable source.

Use a cookies.txt file when browser extraction fails

yt-dlp --cookies cookies.txt "URL"

This is useful when browser-keychain access fails, when you need a repeatable scriptable setup, or when you are troubleshooting a difficult auth problem. Just remember that exported cookies can expire quickly.

YouTube cookies that stop working after a day

YouTube rotates the cookies of a signed-in session while a YouTube tab is open. If you export from the browser you use every day, the file is a copy of a session that keeps moving on without it, and it goes stale within hours or days. The fix the yt-dlp wiki recommends is to export from a session nothing else will touch:

  1. Open a private or incognito window and sign in to YouTube.
  2. In that same tab, go to https://www.youtube.com/robots.txt. Keep it the only private tab open.
  3. Export the youtube.com cookies to cookies.txt with a cookies.txt browser extension. --cookies-from-browser reads your normal profile, not this private session.
  4. Close the private window without signing out, so the session is never opened in a browser again.

Use a separate Google account for this, not your personal one. Heavy automated use can get the account challenged too.

  • wrong browser selected
  • wrong browser profile selected
  • expired login session
  • the OS keychain blocks yt-dlp from reading cookies
  • the site requires more than a simple signed-in session
  • the User-Agent doesn't match the browser the cookies came from. TikTok rejects that with a 403 (fix in the TikTok guide). Don't pin an old User-Agent next to fresh cookies.
  • yt-dlp read no cookies for that site at all, even though the browser is logged in. It happens with Reddit (fix in the Reddit guide).

To see what yt-dlp actually gets, have it write the extracted cookies to a file and look for the site's login cookie. It complains that there's no URL, but it still writes the file. Delete the file afterwards, because it holds your session:

yt-dlp --ignore-config --cookies-from-browser firefox --cookies check.txt
grep -c reddit.com check.txt

The fast debugging move is simple: confirm the content plays in the browser you are extracting from, then rerun the command with that browser explicitly.

"HTTP Error 413: Request Entity Too Large" with --cookies

ERROR: [youtube] <id>: Unable to download API page: HTTP Error 413: Request Entity Too Large

A 413 when passing --cookies means the request yt-dlp sent was too big for the server to accept, and the cookie header is the usual reason. This points at a stale or malformed cookie file, not something you need to tune. A current yt-dlp already drops expired cookies from the jar on its first request to YouTube, so a cookie header large enough to trip 413 almost always means the file was exported wrong or has gone stale.

The fix, in order: update yt-dlp (yt-dlp -U, or update your package) so the expired-cookie handling is current; then re-export your cookies cleanly rather than reusing an old file. Pulling straight from the browser with --cookies-from-browser avoids a hand-exported file drifting out of date. If you keep a cookies.txt, regenerate it from a fresh logged-in session instead of editing the old one by hand. Only pass cookies when the content actually needs a signed-in session — many downloads do not.

What not to do

  • do not assume old exported cookies will keep working forever
  • do not guess the browser name or profile
  • do not keep retrying broken commands without verifying the browser session still works
  • do not use cookies for content you are not authorized to access

Cookies on a server or in automation

Both methods above assume a logged-in browser on the same machine. On a headless server, a CI runner, or a container there is no browser profile for --cookies-from-browser to read, so that flag has nothing to pull from and errors out. That leaves a cookies.txt file, which works but is a live login you now have to store as a secret - and session cookies expire, so a job that ran last week starts failing with 401/403 once the file goes stale.

The usual pattern is to export a fresh cookies.txt on a machine that is signed in, copy it to the server, and re-export it whenever it rots.

--cookies FILE isn't read-only: yt-dlp writes its cookie jar back to the file when it exits, so the file keeps whatever the site refreshed during the run. In Docker or CI, mount the file somewhere writable and keep it between runs. A read-only mount, or a fresh copy from a secret on every run, throws those updates away.

docker run --rm -v "$PWD/cookies.txt:/cookies.txt" -v "$PWD:/downloads" \
  your-yt-dlp-image --cookies /cookies.txt "URL"

If you are also on a datacenter IP, the IP reputation can block you even with valid cookies - see when cookies still fail on a server.

If this is a download your app runs for its users, re-exporting cookies by hand every time they rot doesn't scale. The block below shows the same download as one API call, with no cookie file to keep alive.

Running this inside your app on a server?

If the download has to keep working in production, the same job is one API call to Importly. You send the link and get the file back at your webhook (or by polling), from servers where self-hosted downloads get blocked. Free to try, no card required.

import os
import requests

# Submit the link; Importly POSTs the finished file to your webhook.
res = requests.post(
    "https://api.importly.io/import",
    headers={"Authorization": f"Bearer {os.environ['IMPORTLY_API_KEY']}"},
    json={
        "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
        "webhookUrl": "https://example.com/webhooks/importly",
    },
)
print(res.json()["data"]["jobId"])  # or poll GET /import/status?id=...

Get a key and make your first call in the quick start, with transcripts and metadata too.

Guides for your stack: Python, Next.js, Laravel, Rails, Go, BullMQ, Celery, Supabase Edge Functions.

Servers & agents

Works on your laptop but not on the server?

Paste a link to see what a hosted API returns, running from servers and agent sandboxes where datacenter IPs get blocked — nothing to install or maintain on the box.

Building this into an app? See the API your backend calls instead

Frequently asked questions

How do I pass cookies to yt-dlp?

Two ways. Pull them straight from your browser with --cookies-from-browser chrome (or firefox, edge, brave, safari), or export a Netscape-format cookies.txt file and pass it with --cookies cookies.txt. The browser option is easiest for a one-off; the file is better for scripts and servers.

How do I use a specific browser profile with yt-dlp?

Add the profile after a colon: --cookies-from-browser "chrome:Profile 1" (or the profile name for Firefox). The full form is BROWSER[+KEYRING][:PROFILE][::CONTAINER]. Without a profile, yt-dlp reads the most recently used one, which is the usual reason it grabs cookies from the wrong account.

Why did --cookies-from-browser stop working or fail to read the database?

On recent Chrome the cookie database is locked while the browser is running, and newer versions encrypt it so yt-dlp cannot decrypt it. Close the browser fully first, or switch to a dedicated browser profile, or export a cookies.txt file instead. Firefox is generally the most reliable source.

Do cookies fix the 'Sign in to confirm you're not a bot' error?

Often, yes, when you are running on your own machine - fresh cookies from a logged-in session let yt-dlp pass the check. On a server or datacenter IP they frequently are not enough, because the IP reputation itself is what triggers the block. In that case cookies help, but the IP is the real problem.

Why do my YouTube cookies stop working after a day?

YouTube rotates the cookies of a session that is still open in a browser, so a file exported from a tab you keep using goes stale. Sign in to YouTube in a private window, open youtube.com/robots.txt in that tab, export the cookies with a cookies.txt extension, then close the window. Keep the file writable, because yt-dlp saves refreshed cookies back to it.

Are yt-dlp cookies safe to share or commit?

No. A cookies.txt file is an active login for your account - anyone with it can act as you. Keep it out of version control, do not paste it into issues, and rotate it (log out and back in) if it leaks.

Why does yt-dlp say my cookies file is not in Netscape format?

yt-dlp rejects a cookies.txt whose first line isn't the Netscape header - the message is `does not look like a Netscape format cookies file`. The file has to start with `# Netscape HTTP Cookie File` (a plain `# HTTP Cookie File` also works), then one tab-separated cookie per line. Export it with an extension that writes that format, or skip the file entirely and use --cookies-from-browser so yt-dlp builds it for you. A cookies.txt saved as JSON or missing that header line trips the same error.

Can my YouTube account get banned for using its cookies with yt-dlp?

Heavy automated downloading tied to your main account's cookies can get that account rate-limited or suspended - the cookies make the traffic clearly yours. If you're running anything at volume or on a server, use a throwaway account rather than your personal one, and expect the cookies to need replacing by hand when they expire.

Do my cookies need to match my browser's User-Agent?

yt-dlp already sends a User-Agent that fits its requests, so you usually should not set one yourself. The trouble starts when you pin an old --user-agent next to freshly exported cookies: some sites check that the session and the User-Agent line up and reject the mismatch (TikTok returns a 403, see the TikTok guide). Export fresh cookies and leave the User-Agent alone unless a specific guide tells you to change it.