How to Configure mpv Media Player to Use a Proxy Server?
This article provides a straightforward guide on how to configure the mpv media player to route its internet streams through a proxy server. Whether you need to bypass regional restrictions, improve routing, or secure your network traffic, you can easily set up mpv to utilize HTTP, HTTPS, or SOCKS proxies. Below, we will cover the temporary environment variable method, permanent configuration file setups, and command-line arguments.
Using Environment Variables
The most common and robust way to force mpv (and its underlying stream downloader, yt-dlp) to use a proxy is by setting network environment variables before launching the player. mpv automatically detects standard proxy variables.
To use an HTTP or HTTPS proxy, set the following variables in your terminal:
- Linux/macOS:
export http_proxy="http://your.proxy.address:port"
export https_proxy="http://your.proxy.address:port"
mpv "https://www.youtube.com/watch?v=example"- Windows (Command Prompt):
set http_proxy=http://your.proxy.address:port
set https_proxy=http://your.proxy.address:port
mpv "https://www.youtube.com/watch?v=example"- Windows (PowerShell):
$env:http_proxy="http://your.proxy.address:port"
$env:https_proxy="http://your.proxy.address:port"
mpv "https://www.youtube.com/watch?v=example"If your proxy requires authentication, format the string like this:
http://user:password@your.proxy.address:port.
Configuring the mpv.conf File
If you want mpv to use a proxy server permanently without typing it
into the terminal every time, you can add the configuration directly to
your mpv.conf file.
- Locate or create your
mpv.conffile:
- Linux/macOS:
~/.config/mpv/mpv.conf - Windows:
C:\Users\Username\AppData\Roaming\mpv\mpv.conf(or thempvfolder where your executable is located).
- Append the following lines to the file:
# HTTP/HTTPS Proxy Configuration
http-proxy=http://your.proxy.address:port
For SOCKS5 proxies, mpv utilizes its stream-handling backend. You can pass the proxy option directly to the network backend using the standard syntax:
# SOCKS5 Proxy Configuration
ytdl-raw-options=proxy="socks5://127.0.0.1:1080"
Command-Line Arguments for Single Sessions
If you only need to use a proxy for a specific video or stream during a single session, you can pass the proxy settings directly as a command-line argument when launching mpv.
For standard HTTP/HTTPS streams:
mpv --http-proxy="http://your.proxy.address:port" "https://example.com/stream.mp4"For YouTube, Twitch, or other sites handled by yt-dlp, pass the proxy argument directly to the script backend:
mpv --ytdl-raw-options=proxy="socks5://127.0.0.1:1080" "https://www.youtube.com/watch?v=example"