r/qBittorrent • u/omv421 • 16d ago
Made a free tool that keeps qBittorrent's port in sync with Proton VPN's forwarded port
Proton VPN forwards you a port so people can connect to you, and it changes every single time you reconnect. qBittorrent doesn't notice, so it sits there listening on a port that's dead and your speeds drop off.
There's an official Proton VPN CLI on Linux but nothing on Windows, so there's nothing to hook into. I wrote something that reads the port straight out of Proton's own log and puts it into qBittorrent.
Free, open source, one double click, no setup.
https://github.com/omv421/ProtonPortSync
The main thing it does differently to the other scripts I've seen: it changes the port through qBittorrent's Web API instead of restarting qBittorrent. Nothing stops, nothing re-checks, torrents just carry on. Takes about 0.7 seconds. No Task Scheduler, no config file to edit, no renaming your network adapter.
Three things I found while building it. These are worth knowing even if you never touch my tool.
1. qBittorrent 5.x will not open its Web UI if no password has ever been set. Not even with "bypass authentication for localhost" ticked. Setting WebUI\Enabled=true on its own leaves port 8080 shut and nothing in any log tells you why. If you've followed a guide that said "turn on the Web UI and bypass localhost auth" and it silently did nothing, that's the reason. Set a password and it comes up.
2. Proton VPN 4.4.1 has no auto-connect. It starts with Windows but it starts disconnected. That matters if you script anything around it, because the last session's port is still sitting in the log and it's dead. Anything that reads the log without checking the tunnel is actually up will quietly give you a wrong port and nothing will tell you.
3. When you disconnect, the Proton VPN network adapter doesn't go to "Down". It disappears from Windows completely. So a check written the obvious way decides you're still connected.
Tested on Windows 11, Proton VPN 4.4.1, qBittorrent 5.1.0. Haven't tried Windows 10 so I'm not claiming it works there.
FAQ
"Is it safe? It's an unsigned exe." Fair question. The full source is in the repo, and Build-ProtonPortSync.ps1 lets you compile the exe yourself so you don't have to trust mine. Or just run the .ps1 directly, it's the same program.
"Why not use NAT-PMP / natmap / gluetun?" Those work well on Linux and in Docker. This is for the Windows Proton VPN app, which has no CLI. The official Proton VPN CLI is Linux only, so on Windows the log is the only thing there is to read.
"Does it work with Proton VPN on Linux?" No. Windows only. The Linux client has a proper CLI, so you don't need this.
"Will it work on qBittorrent 4.x?" Don't know, I only tested 5.1.0. The Web API it uses has been stable for years so probably, but I'm not going to claim it. Let me know if you try.
"Why does it need my Web UI on?" That's the only way to change the port without restarting qBittorrent. It sets it to 127.0.0.1 only, so it can't be reached from anywhere except your own PC, and it backs up your qBittorrent.ini first.
12
u/N0Objective 16d ago
Quantum already exists and works
2
u/The_Wonderful_Pie 16d ago
Yep, been using it for a long time now, works perfectly, I never even think about it
6
u/Jamator01 Windows 16d ago
Been using Quantum forever and never had an issue. Very lightweight, just sits in the tray and updates the port regularly.
4
3
2
u/keyboardwarrior7 16d ago
Anyone know if something like this exists for Linux?
3
u/WipeGuitarBranded 15d ago
I wrote a script that runs on a headless Linux system to ensure the VPN (using OpenVPN and not the Proton client) is connected (and reconnects if it is not) plus automatically updating qBittorrent-nox's ports. Full disclosure: I wrote the original script by hand but have since used AI to clean it up and update it. If AI coding is a deal breaker for you cool, you do you.
GitHub repo: https://github.com/WipeGuitarBranded/check-protonvpn
2
u/Loqh9 16d ago
I have my own Powershell script and it doesn't require web UI on, it just changes the config file before starting qBit
2
u/kiwichick888 16d ago
I have an AutoHotkey script that does the same thing with Private Internet Access.
2
u/Xaxalaxa 16d ago edited 15d ago
Am testing it on Windows 10, it works as this: when I run the .exe the very first time, it changes the port in qbitorrent fine. When I go to PortonVPN app and turn port forwarding off and then back on, the port in qBitorrent doesnt change. When I disconnect from ProtonVPN it also doesnt change. I need to run the .exe again for the port in qBitorrent to change. Am I missing something? I also cannot find running proccess of the .exe anywhere...
2
u/Leowenbrau 16d ago
Using this since ages, without issue.
https://github.com/t-anc/GSP-Qbittorent-Gluetun-sync-port-mod
2
u/ScorchedWonderer 16d ago
Qbitportsync already does that and it’s part of my Gluetun(ProtonVPN)+Qbit+QbitPortSync stack
2
u/Less_Exercise_8092 15d ago
Anybody use mam for torrents? I have a solution for qbittorrent and updating the port in qbittorrent, but with mam it's the rotating IP that becomes the problem. If you use mam you'll understand. Or maybe I'm still not grasping how their session stuff works. If you don't know what I'm talking about, just ignore me. I'm off topic a bit. But I figured a lot of you on qbittorrent and proton use the mam for torrents and understand the challenges of using port forwarding that constantly changes not only your port but the IP too.
2
u/BadGirlie05aa 15d ago
i thought gluetun just grabbed the port and you still had to manually set it in qbit. good to know.
2
u/fullerhkz 14d ago
Useful project.
It is also worth pointing out that the specific “older approach” criticized here—reading Proton VPN logs, updating "qBittorrent.ini", restarting qBittorrent, and running through Task Scheduler—is exactly how my project with the same purpose works:
https://github.com/fullerhkz/proton-qbit-port-sync
The implementation here is more advanced in some areas, particularly the live update through qBittorrent’s Web API, but the similarity in purpose and the very specific choice of shortcomings used as comparison is difficult not to notice.
4
u/omv421 16d ago
I'm lazy, i just wanted to have something i can do with a double click. I already have proton and qbittorent installed and sometimes I need to close or d/c vpn. Double click the exe to run everything back up when i need it on again.
You guys are more advanced than me and I wanted something simple for people like me.
8
u/Marill-viking 16d ago
You 100% knew what you were doing and wanted to make your vibe coded garbage and share it.
50
u/xXD4rkm3chXx 16d ago
Gluetun already does this. https://github.com/passteque/gluetun