Secure Torrenting: qBittorrent with VPN Kill Switch
If you're using torrents, protecting your privacy is essential. Here's how to set up qBittorrent with a built-in VPN and kill switch using Docker.
Why VPN for Torrents?
When torrenting:
- Your IP is visible to everyone in the swarm
- Your ISP can see your traffic
- Copyright trolls actively monitor popular torrents
A VPN:
- Hides your real IP
- Encrypts traffic from ISP
- Provides deniability
The Kill Switch Problem
A regular VPN connection can drop without warning. If that happens, qBittorrent continues downloading with your real IP exposed.
Solution: Use a container that won't allow any traffic without VPN.
qBittorrent + VPN Docker Setup
We use binhex's image which integrates OpenVPN/WireGuard:
services:
qbittorrent:
image: binhex/arch-qbittorrentvpn
container_name: qbittorrent
cap_add:
- NET_ADMIN
environment:
- VPN_ENABLED=yes
- VPN_PROV=custom
- VPN_CLIENT=openvpn
- ENABLE_PRIVOXY=no
- LAN_NETWORK=192.168.1.0/24
- NAME_SERVERS=1.1.1.1,8.8.8.8
- PUID=1000
- PGID=1000
- WEBUI_PORT=8080
- UMASK=022
- TZ=America/New_York
volumes:
- qbit_config:/config
- /path/to/downloads:/data/downloads
- /path/to/vpn:/config/openvpn # VPN config files
ports:
- "8080:8080" # Web UI
- "6881:6881" # Torrent port (optional)
- "6881:6881/udp"
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
restart: unless-stopped
volumes:
qbit_config:
VPN Provider Setup
NordVPN
- Download OpenVPN config from NordVPN
- Place
.ovpnfile in/config/openvpn/ - Create credentials file:
your_username
your_password
- Update the
.ovpnfile to reference credentials:
auth-user-pass /config/openvpn/credentials.conf
ProtonVPN
- Download OpenVPN config from account dashboard
- Note: Use OpenVPN credentials, not account password
- Same process as NordVPN
Verifying the Kill Switch
Test that the kill switch works:
# Get container's external IP
docker exec qbittorrent curl -s https://ipinfo.io/ip
# Stop VPN inside container (simulating failure)
docker exec qbittorrent pkill openvpn
# Try to get IP again - should fail
docker exec qbittorrent curl -s --max-time 5 https://ipinfo.io/ip
# No response = kill switch working!
DNS Leak Testing
Even with VPN, DNS requests can leak. Test with:
- Go to
https://dnsleaktest.comfrom the container:
docker exec qbittorrent curl -s https://dnsleaktest.com/
-
Or check in qBittorrent's web UI if it shows your location
-
Use our DNS Leak Testing guide
Port Forwarding
Some VPN providers support port forwarding for better speeds:
- Mullvad - Dynamically assigned ports
- AirVPN - Manual port selection
- Private Internet Access - Port in app settings
Configure in qBittorrent:
- Settings → Connection
- Set "Listening Port" to your forwarded port
- Disable "Use UPnP / NAT-PMP"
Arr Stack Integration
Connect qBittorrent to Radarr/Sonarr:
- In Radarr: Settings → Download Clients → Add
- Select qBittorrent
- Host:
qbittorrent(container name) or192.168.1.x - Port:
8080 - Username/Password from qBittorrent settings
Category Setup
Create categories in qBittorrent:
moviesfor Radarrtvfor Sonarrmusicfor Lidarr
Set save paths:
/data/downloads/torrents/movies/data/downloads/torrents/tv
Troubleshooting
VPN won't connect
docker logs qbittorrent 2>&1 | grep -i vpn
Check credentials and config file paths.
Web UI not accessible
Verify LAN_NETWORK matches your actual network.
Slow speeds
- Try different VPN servers
- Enable port forwarding if available
- Check if ISP throttles VPN traffic
My Setup
Currently using:
- Proton VPN
- OpenVPN protocol
- Port forwarding disabled
- Connected to Radarr, Sonarr, Lidarr
Learn More
What VPN do you use for torrenting? Share on Discord!
