Skip to content

Start typing. Errors match on their exact yt-dlp output.

to move, to open esc to close

yt-dlp Cookies: --cookies-from-browser vs cookies.txt

Tested on yt-dlp 2026.07.28 Updated

Quick answer

Cookies are how yt-dlp proves it is you — for private videos, members-only content and anything behind a login. Two ways to supply them. Firefox is the one that works without a fight:

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

What cookies do and do not do

A cookie carries a session identifier. Sending it makes the request look like it came from your signed-in browser, which is exactly what you want for content gated on an account.

What it does not do is prove the request came from a browser at all. YouTube now checks that separately, with a proof-of-origin token that yt-dlp cannot produce. That is why supplying cookies often does nothing for "Sign in to confirm you're not a bot" — the error asks for cookies, and cookies are not what is missing.

ProblemCookies help?
Private video you have access toYes
Members-only contentYes
Age-restricted videoYes, if the account is verified
Purchased or rented contentYes
"Sign in to confirm you're not a bot"Rarely — see the bot check page
HTTP 403No — that is an expired URL
HTTP 429No — and it may make it worse

Method 1 — read the browser directly

Nothing to export, nothing to keep current:

bash
yt-dlp --cookies-from-browser firefox "URL"
yt-dlp --cookies-from-browser "firefox:Work" "URL"

Supported: firefox, chrome, chromium, edge, brave, opera, vivaldi, safari, whale.

In practice this splits cleanly in two. Firefox works while it is open. Chromium browsers do not:

  • They hold an exclusive lock on the cookie database while running, so Chrome has to be fully closed — including background processes — or the copy fails.
  • Since Chrome 127 the cookies are encrypted with a key bound to the browser process, so even a perfect copy decrypts to nothing.
  • On Linux, the key lives in the desktop keyring, which does not exist over SSH — permission denied.

Method 2 — export a cookies.txt

Works from any browser including recent Chrome, and it is the only option for anything scheduled or headless. Install an extension that exports Netscape format, export while on the site, then:

bash
yt-dlp --cookies cookies.txt "URL"
chmod 600 cookies.txt

Netscape format, which is what yt-dlp reads, looks like this. If your export is JSON, it is the wrong format:

cookies.txt
.youtube.com	TRUE	/	TRUE	1785312000	SID	g.a000xxxxxxxx
.youtube.com	TRUE	/	TRUE	1785312000	HSID	Axxxxxxxxxxxx

Choosing between them

Read the browsercookies.txt
SetupNoneAn extension, and a re-export now and then
Stays currentAutomaticallyNo — expires
Works headlessNoYes
Works in DockerNoYes
Chrome 127+NoYes
Leaves a credential on diskNoYes

Interactive use on a desktop: read the browser, and use Firefox. Anything automated: export a file, lock its permissions, and expect to replace it.

Verifying

bash
yt-dlp --cookies-from-browser firefox --simulate -v "URL"

Verbose output states how many cookies were extracted. Zero means the wrong profile or browser. Several hundred with access still refused means the session is valid and the account lacks permission — see private video.

Keeping the file safe

A cookies.txt is a live session in plain text. Anyone who reads it is signed in as you, without a password and without a second factor.

  • chmod 600, so other accounts on the machine cannot read it.
  • Not in a git repository. Add it to .gitignore before you create it, not after.
  • Not in Dropbox, OneDrive or iCloud.
  • Mounted read-only into containers.
  • Deleted when the job is done, and re-exported next time.

Combining with a client override

On YouTube you often need both — the account for access, and a client that is not separately challenged:

bash
yt-dlp --cookies-from-browser firefox --extractor-args "youtube:player_client=web_safari" "URL"

Avoid pairing cookies with player_client=tv: it authenticates differently and the mismatch can invalidate the session, logging you out of the browser you exported from.

Frequently asked

Do cookies fix the bot check?
Not on their own, and this is the most common misunderstanding. Cookies prove who you are; the bot check asks where the request came from. They are separate questions and answering one does nothing for the other.
Which browser is easiest?
Firefox, by a wide margin. It does not lock its cookie database while running and does not tie decryption to the browser process, so --cookies-from-browser just works. Chromium browsers fail in both of those ways.
How long do exported cookies last?
Days to weeks, unpredictably. Sessions rotate, and faster for accounts a site considers unusual. Any script relying on a cookies.txt should be expected to need a fresh one periodically.
Can I share a cookies.txt with someone?
You can, and it means handing them your account. The file is a live session in plain text — anyone holding it is signed in as you, with no password needed and no second factor asked for.