Skip to content

Instantly share code, notes, and snippets.

@sam-kleiner
Created September 21, 2025 06:57
Show Gist options
  • Select an option

  • Save sam-kleiner/9f8569c1dac70937610e1f8e9ebc4580 to your computer and use it in GitHub Desktop.

Select an option

Save sam-kleiner/9f8569c1dac70937610e1f8e9ebc4580 to your computer and use it in GitHub Desktop.
Auto sync ProtonVPN forwarded port to qBittorrent

ProtonVPN qBittorrent sync

See: https://protonvpn.com/support/port-forwarding

These systemd configs will watch for changes to /run/user/$UID/Proton/VPN/forwarded_port as described in the support article. When a change is detected it will trigger the service to update the qbittorrent config via the api.

If your qBittorrent api requires a password you will need to modifiy the curl command.

This assume user level systemd.

Files

At minimum you need the proton-qbit-port-sync.path and proton-qbit-port-sync.service.

protonvpn.conf only applies if you are using the protonvpn flatpak.

  • .config/systemd/user/proton-qbit-port-sync.path
  • .config/systemd/user/proton-qbit-port-sync.service
  • .config/user-tmpfiles.d/protonvpn.conf

Apply

systemctl --user daemon-reload
systemctl --user enable proton-qbit-port-sync.path

Flatpak

If you are using flatpak you should also add the protonvpn.conf to ensure the run directory always exists. systemd-tmpfiles can be used to apply the change immediately.

The flatpak config needs to be updated to allow it to access /run/user/$UID/Proton/VPN/forwarded_port.

systemd-tmpfiles --user --create
flatpak override --user --filesystem=/run/user/$(id -u)/Proton/VPN com.protonvpn.www

Status & Logs

systemctl --user status proton-qbit-port-sync.path
systemctl --user status proton-qbit-port-sync.service
journalctl -xe --user-unit proton-qbit-port-sync.service
[Unit]
Description=Watch for ProtonVPN forwarded port changes
[Path]
PathModified=/run/user/%U/Proton/VPN/forwarded_port
[Install]
WantedBy=default.target
[Unit]
Description=Update qBittorrent port based on ProtonVPN forwarded port
[Service]
Type=oneshot
ExecStart=curl -vm 5 --variable port@/run/user/%U/Proton/VPN/forwarded_port --expand-data 'json={"listen_port": {{port}} }' http://127.0.0.1:8080/api/v2/app/setPreferences
d %t/Proton/VPN 0755 - - -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment