Error

Ive been successfully using that exact stack for a few months. I'd recommend using wireguard instead of openvpn.

Also, add a the gluetun health check and add condition: service_healthy to your qbittorrent dependency.

You can also simplify your port forwarding quite a bit. Here's a link to how I have it setup. Qbittorrent won't start until gluetun has a healthy connection. Then it repeatedly runs your port forwarding command until it gets an OK exit.

Port forwarding for torrenting shouldn't affect your webui accessibility so it's also possible your qbittorrent is failing before gluetun comes in.

I know that the port forwarding command can be simplified. In my case its this complex because the way it is listed in the gluetun wiki did not work even though I disabled authentication for my local network. The largest part of the script is authenticating with the username and password before actually sending the port forwarding command.

I'll definitely try adjusting my stack to your variant though. I've also tried the healthcheck option before but I must have configured it wrong because that caused my gluetun container to get stuck.

One question regarding your stack though, is there a specific reason for binding /dev/net/tun to gluetun?

That's recommended by glutun.

https://github.com/qdm12/gluetun-wiki/blob/main/setup/providers/protonvpn.md#protonvpn

You'll need to whitelist localhost authentication in qbittorrent settings as well.

I guess I missed that.

Anyway, I updated my stack to be similar to what you pasted and so far it seems to be working. I'll have to check tomorrow if the reboot issue persists.

Hey, just wanted to let you know that my updated stack has been running perfectly since I changed it based on your setup. Thanks

Not the best solution but I will leave it in case no one else comments; maybe consider a different vpn provider that does not assign a port on every connection such as mullvad. You should be able to follow this example: https://github.com/JamesTurland/JimsGarage/blob/main/Torrent-VPN/docker-compose.yml

As far as I am aware, Mullvad has removed port forwarding support a while ago. While I am not sure which VPN providers except proton still support it, I kind of remember seeing a small list of them some time ago which listed Proton among one of the few trustworthy ones left.

This doesn't help your specific problem, but for what it's worth: airvpn allows you to set a port # which is retained when the VPN hops to a new server, or is reset. In other words, I set the port # in airvpn a year ago, and i have kept the same port since. I haven't kept super up to date on VPN trustworthiness, so maybe airvpn is no longer recommended.

PIA has port forwarding and retains the port between connections.

I use AirVPN, which gives you a random static port for port forwarding.

Gluetun has an example for qbt port forwarding integration on the wiki. I've been using this for about a year and some without problem (to my knowledge at least). I've seen that gluetun will retry setting the port in qbt for a while to work around the timing issues.

They also mention a bug in qbt when changing the port, which is also covered in the example.

Edit: I see you're already using the port down script. Not sure what else could be the root cause if you're running on an up to date container version :/

Here another option using wireguard with protonvpn and a docker extension to update the proton port forwarding port.

You would just need to update the volume mounts per your system.

# docker-compose.yml

  gluetun:
    image: qmcgaw/gluetun:latest
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - VPN_SERVICE_PROVIDER=protonvpn
      - SERVER_COUNTRIES=Canada
      - VPN_TYPE=wireguard
      - WIREGUARD_PRIVATE_KEY=${WIREGUARD_PRIVATE_KEY}
      - VPN_PORT_FORWARDING=on
      - PORT_FORWARD_ONLY=on
    ports:
      - 8888:8888 # Gluetun HTTP proxy port
      - 8000:8000 # Gluetun HTTP control server
      - 8080:8080 # qBittorrent WebUI port
    volumes:
      - /docker/appdata/gluetun:/config  
      - /docker/appdata/gluetun/config.toml:/gluetun/auth/config.toml
    restart: unless-stopped

  qbittorrent:
    image: lscr.io/linuxserver/qbittorrent:latest
    container_name: qbittorrent
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - WEBUI_PORT=8080
      - DOCKER_MODS=ghcr.io/t-anc/gsp-qbittorent-gluetun-sync-port-mod:main|ghcr.io/vuetorrent/vuetorrent-lsio-mod:latest
      - GSP_GTN_API_KEY=YOUR_DOCKERMOD_APIKEY
    healthcheck:
      test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8080/"]
      interval: 30s
      timeout: 10s
      retries: 5
    depends_on:
      gluetun:
        condition: service_healthy # Wait for VPN to be up first
    volumes:
      - /docker/appdata/qbittorrent:/config
      - ${DATA_PATH}:/data
    restart: unless-stopped  
    network_mode: service:gluetun
# config.toml for docker extension

[[roles]]
name = "t-anc/GSP-Qbittorent-Gluetun-sync-port-mod"
routes = ["GET /v1/portforward"]
auth = "apikey"
apikey = "YOUR_DOCKERMOD_APIKEY"

This setup works flawlessly for me, even with Proton switching ports each time I reconnect.

Thanks. I'll keep this in mind in case my new stack causes issues again