Tutorial
|
by Hunt Team

How to use Proxies for yt-dlp (HTTP, SOCKS5 & Tor)

yt-dlp is the most powerful video downloader available today, but even it has limits. You might encounter geo-restricted videos that are only available in specific countries, or IP bans from sites that detect too many requests.

The solution is to route your traffic through a proxy. This guide covers everything you need to know about using proxies with yt-dlp, from simple HTTP setups to advanced privacy protection with Tor.

Why Use a Proxy with yt-dlp?

  1. Bypass Geo-Blocking: Watch and download content restricted to specific regions (e.g., BBC iPlayer from outside the UK, or Crunchyroll libraries).
  2. Avoid Rate Limiting: If you are archiving a channel or downloading a playlist, sites like YouTube might temporarily block your IP (Error 429). Rotating proxies helps avoid this.
  3. Privacy: Hide your home IP address from the sites you interact with.

Basic Proxy Usage

The primary flag for using a proxy in yt-dlp is --proxy. It supports HTTP, HTTPS, and SOCKS protocols.

HTTP/HTTPS Proxies

This is the most common type of proxy.

yt-dlp --proxy "http://user:[email protected]:8080" "https://www.youtube.com/watch?v=..."

Syntax Breakdown:

  • http:// - Protocol (can often be omitted, but best to be explicit).
  • user:password - (Optional) Authentication if your proxy requires it.
  • @ - Separator between credentials and the server address.
  • proxy.example.com - The IP or hostname of the proxy server.
  • 8080 - The port number.

SOCKS5 Proxies

SOCKS5 is often preferred for more versatile traffic tunneling.

yt-dlp --proxy "socks5://user:[email protected]:1080" "https://..."

Using yt-dlp with Tor

For maximum privacy, or to bypass difficult censorship, you can route yt-dlp through the Tor network.

Prerequisite: You must have the Tor service installed and running on your machine. By default, Tor opens a SOCKS5 proxy on port 9050.

yt-dlp --proxy "socks5://127.0.0.1:9050" "https://www.youtube.com/watch?v=..."

Note: Downloading over Tor will be significantly slower than a standard connection. It is best reserved for content that cannot be accessed any other way.

Permanent Configuration

Typing the proxy URL every time is tedious. You can save your proxy settings in a configuration file.

  1. Create or edit your config file:
    • Linux/macOS: ~/.config/yt-dlp/config
    • Windows: %APPDATA%\yt-dlp\config
  2. Add the proxy line:
--proxy "http://user:[email protected]:8080"

Now, every time you run yt-dlp, it will automatically use this proxy.

Dealing with "429 Too Many Requests"

If you are scraping data or downloading massive playlists, a single proxy might get banned. In this case, you need a proxy rotation strategy.

While yt-dlp doesn't have a built-in "rotator," you can achieve this by using a proxy provider that handles rotation on their end (providing a single entry point that changes exit IPs), or by writing a simple wrapper script that cycles through a list of proxies.

Example: Using a Rotating Proxy Service

Many premium proxy services provide a "sticky" or "rotating" gateway.

# Example for a service that rotates IP on every request
yt-dlp --proxy "http://rotating-gateway.provider.com:port" ...

Troubleshooting

"Connection Refused"

  • Verify the proxy IP and port are correct.
  • Check if your firewall is blocking the connection.
  • If using Tor, ensure the Tor Browser or background service is actually running.

"Proxy Authentication Required"

  • Ensure you have included the user:password part in the URL.
  • If your password contains special characters (like @ or :), you must URL encode them (e.g., @ becomes %40).

Geo-Restriction Persists

  • Some free proxies leak your real DNS or IPv6 address. Use --force-ipv4 to ensure traffic goes through the IPv4 proxy tunnel.
  • Verify the location of your proxy IP using a tool like curl --proxy ... ipinfo.io.

VIDEO API

Discover why Hunt is the preferred API provider for developers.