January 9, 20251 yr Hey fellow Unraid users! Hey fellow Unraid users!I wanted to share a handy User Script for UnRaid that I created to automate updating qBittorrent's listening port to match the forwarded port provided by the Gluetun VPN client. This eliminates the need for manual configuration and ensures your torrents are always optimized for connectivity. It is designed specifically for UnRaid users who utilize both qBittorrent and Gluetun VPN client in a Docker environment. 🔗 Source CodeYou can find the complete script and additional resources on GitHub: https://github.com/RzrZrx/Gluetun-qBittorrent-Port-Updater-Script-For-unRAID What is Gluetun VPN client?Gluetun is a lightweight and versatile VPN client that works with multiple VPN service providers. It runs in a compact Docker container, written in Go, and supports both OpenVPN and WireGuard protocols. Additionally, it features DNS over TLS for secure DNS queries and built-in proxy servers for added functionality. Supported VPN Providers:AirVPN, Cyberghost, ExpressVPN, FastestVPN, Giganews, HideMyAss, IPVanish, IVPN, Mullvad, NordVPN, Perfect Privacy, Privado, Private Internet Access (PIA), PrivateVPN, ProtonVPN, PureVPN, SlickVPN, Surfshark, TorGuard, VPNSecure.me, VPNUnlimited, VyprVPN, WeVPN, Windscribe. Updated for Gluetun v3.40.0The script has been updated to support the v3.40.0 changes, which introduced authentication for accessing the /v1/openvpn/portforwarded endpoint. This ensures compatibility with the new authentication mechanism, providing seamless port-forwarding functionality. Installation GuidePrerequisitesA Gluetun container (VPN Client).A qBittorrent container.Port Forwarding enabled in your VPN provider settings.Step 1: Save the ScriptDownload the latest script (update_qbittorrent_listening_port.sh).Save it to a persistent location on your server (e.g., /mnt/user/appdata/gluetun/scripts/).Step 2: File PermissionsBefore running the script, ensure it is executable. Use one of the following methods:Option 1: From Unraid Host TerminalRun the following command in your Unraid terminal:chmod +x /mnt/user/appdata/gluetun/scripts/update_qbittorrent_listening_port.shOption 2: From Gluetun ConsoleUse the following command inside the Gluetun VPN Client Console:chmod +x /tmp/gluetun/update_qbittorrent_listening_port.shStep 3: Gluetun Docker ConfigurationFor the script to work, it must be able to communicate with the Gluetun Control Server (port 8000).1. Set Gluetun Credentials (Required)This is the step where you CREATE the Username and Password (or API Key) for Gluetun. You are definingthese credentials now so the script can log in to the VPN container later.Choose ONLY ONE of the following methods (Method 1 or Method 2).Tip: If you prefer API Key authentication, run this command in the Unraid terminal to generate arandom key:docker run --rm qmcgaw/gluetun genkey # Output example: 5HuQ3QpsZ7o6XKbawtvgvEYMethod 1: Environment Variable (For the lazies not willing to setup a configuration file)Use the HTTP_CONTROL_SERVER_AUTH_DEFAULT_ROLE variable to set your credentials globally.Add this Variable to your Gluetun container:Config Type: VariableName: HTTP_CONTROL_SERVER_AUTH_DEFAULT_ROLEKey: HTTP_CONTROL_SERVER_AUTH_DEFAULT_ROLEValue: (Copy one of the JSON strings below)Description: Defines the Gluetun Control Credentials.Option A: Basic Authentication (User/Pass)Replace my_gt_username and my_gt_password with the actual credentials you want to use.{"auth":"basic","username":"my_gt_username","password":"my_gt_password"}Option B: API Key Authentication Replace the apikey value with your generated key.{"auth":"apikey","apikey":"5HuQ3QpsZ7o6XKbawtvgvEY"}Note: Remember the credentials you set here. You will need to enter these exact values into the script variables in the next step.Method 2: Configuration File Advanced (Recommended)Use HTTP_CONTROL_SERVER_AUTH_CONFIG_FILEPATH to point to a TOML file.This allows for multiple roles and fine-grained control.1. Create the Config File Create a file named config.toml on your host (e.g.,/mnt/user/appdata/gluetun/auth/config.toml).Example TOML (Basic Auth):[[roles]] name = "qbittorrent" routes = [ # Port Forwarding "GET /v1/portforward", # Public IP "GET /v1/publicip/ip" ] auth = "basic" username = "my_gt_username" password = "my_gt_password" Example TOML (API Key):[[roles]] name = "qbittorrent" routes = [ # Port Forwarding "GET /v1/portforward", # Public IP "GET /v1/publicip/ip" ] auth = "apikey" apikey = "5HuQ3QpsZ7o6XKbawtvgvEY"2. Mount the Config File1. Mount the Config File In your Gluetun Docker settings, add a new Path:Config Type: PathName: HTTP_CONTROL_SERVER_AUTH_CONFIG_FILEPATHContainer Path: /gluetun/auth/Host Path: /mnt/user/appdata/gluetun/auth/Access: Read OnlyDescription: Defines the path where Gluetun finds the config.toml file3. Add Script & Status Mappings (Required for Host Logs)Add the Status File Path:Config Type: PathName: PORT_FORWARDING_STATUS_FILEContainer Path: /tmp/gluetunHost Path: /mnt/user/appdata/gluetun/scripts/Access: Read/WriteDescription: Defines the path where Gluetun writes status files (and where our script resides).4. Configure Standard Gluetun VariablesNote: These variables may already exist in your Gluetun template. If they do, *Edit** the existing values. If they do not exist, Add them as new Variables.*Enable Port Forwarding Only:Config Type: VariableName: PORT_FORWARD_ONLYKey: PORT_FORWARD_ONLYValue: trueDescription: Forces Gluetun to only connect to servers that support port forwarding.Activate VPN Port Forwarding:Config Type: VariableName: VPN_PORT_FORWARDINGKey: VPN_PORT_FORWARDINGValue: onDescription: Enables port forwarding on the VPN server.Automation Command:Config Type: VariableName: VPN_PORT_FORWARDING_UP_COMMANDKey: VPN_PORT_FORWARDING_UP_COMMANDValue: /bin/sh -c /tmp/gluetun/update_qbittorrent_listening_port.shDescription: Specifies the command to execute whenever the port forwarding status is updated.5. Port Mappings (Add these to GLUETUN)Since qBittorrent is attached to Gluetun's network, you must define the WebUI ports inside the Gluetuncontainer settings, not qBittorrent.qBittorrent WebUI Port:Config Type: PortName: bittorrent WebUI PortContainer Port: 8080Host Port: 8080Connection Type: TCPDescription: Configures the port used by qBittorrent’s web user interface, default port 8080.Firefox/Chromium WebUI Port (Optional):Config Type: PortName: Firefox WebUI PortContainer Port: 3000Host Port: 3000Connection Type: TCPDescription: Configures the port used by the web user interface, default port 3000.Step 4: Add Custom Script VariablesImportant: The variables below are specific to this automation script and are NOT part of the standard Gluetun image.You must click "Add another Path, Port, Variable..." and Add these as NEW Variables.Internal IP Address:Config Type: VariableName: PORTSYNC Internal IPKey: PORTSYNC_INTERNAL_ADDRESSDefault Value: 127.0.0.1Description: The IP address used to communicate between containers. Leave as default if containersshare the same network stack (Sidecar/Bundle).Gluetun API Port:Config Type: VariableName: PORTSYNC Gluetun API PortKey: PORTSYNC_GT_PORTDefault Value: 8000Description: The port Gluetun's API listens on (Control Server), default port 8000.qBittorrent WebUI Port:Config Type: VariableName: PORTSYNC qBittorrent PortKey: PORTSYNC_QB_PORTDefault Value: 8080Description: The WebUI port of qBittorrent, default port 8080).Note: If your qBittorrent uses different port you must change this variable.qBittorrent CredentialsqBittorrent Username:Config Type: VariableName: PORTSYNC qBittorrent UsernameKey: PORTSYNC_QB_USERNAMEDefault Value: my_qb_username (Replace with your qBittorrent Username)Description: Your qBittorrent WebUI username.qBittorrent Password:Config Type: VariableName: PORTSYNC qBittorrent PasswordKey: PORTSYNC_QB_PASSWORDDefault Value: my_qb_password (Replace with your qBittorrent Password)Description: Your qBittorrent WebUI password.Gluetun CredentialsChoose ONE of the following methods to match your Gluetun Control Server configuration.Method 1: Basic Authentication (User/Password)Use this if you configured Gluetun with a username and password.Gluetun Username:Config Type: VariableName: PORTSYNC Gluetun UsernameKey: PORTSYNC_GT_USERNAMEDefault Value: my_gt_username (Replace with your Gluetun Username)Description: Gluetun Control Server username.Gluetun Password:Config Type: VariableName: PORTSYNC Gluetun PasswordKey: PORTSYNC_GT_PASSWORDDefault Value: my_gt_password (Replace with your Gluetun Password)Description: Gluetun Control Server password.Method 2: API Key AuthenticationUse this if you configured Gluetun with an API Key.Gluetun API Key:Config Type: VariableName: PORTSYNC Gluetun API KeyKey: PORTSYNC_GT_API_KEYDefault Value: 5HuQ3QpsZ7o6XKbawtvgvEY (Replace with your Gluetun API Key)Description: The 22-character API key generated by Gluetun.Script BehaviorWait Timeout:Config Type: VariableName: PORTSYNC Wait TimeoutKey: PORTSYNC_TIMEOUTDefault Value: 300Description: Time (in seconds) to wait for qBittorrent to start before giving up.Debug Mode:Config Type: VariableName: PORTSYNC Debug ModeKey: PORTSYNC_DEBUGDefault Value: falseDescription: Set to true to enable verbose logging to file (/tmp/gluetun/portsync_debug.log).Step 5: qBittorrent Docker ConfigurationFor this setup to work, qBittorrent must route its traffic through the Gluetun container.1. Network SetupWhen routing traffic through the Gluetun container, you must ensure the WebUI URL in the Unraid Dockertemplate does not use Unraid’s default placeholder syntax.Instead of using the template defaults, replace the entry with your server’s actual static IP address and themapped port.Change from: http://[IP]:[PORT:8080]Change to: http://192.168.1.50:8080 (Replace with your Unraid Server IP)Important: This rule applies to all containers that route their traffic through Gluetun (e.g.,sabnzbd, hexchat, firefox). Hardcoding the IP ensures the WebUI icon in the Unraid dashboardfunctions correctly.qBittorrent - Environment variables (Unraid 6.12.14)Turn on Advanced view in templateWebUI: http://192.168.1.50:8080/ (Replace with your actual Server IP)Extra Parameters: --net=container:GluetunVPNNetwork Type: NoneqBittorrent - Environment variables (Unraid 7)Turn on Advanced view in templateWebUI: http://192.168.1.50:8080/ (Replace with your actual Server IP)Network Type: ContainerContainer Network: GluetunVPNTroubleshootingDebug Mode (Finding the Logs)If the script isn't working, enable Debug Mode to see exactly what is happening.Add the variable PORTSYNC_DEBUG with value true to your **Gluetun** container.Restart the Gluetun container.To view the logs, you must verify where they are.Important: This script runs inside the Gluetun container.Therefore, the log file is created inside Gluetun, NOT inside the qBittorrent container.Method A: Check inside the container (Guaranteed to work)Run this command in the Unraid terminal:docker exec -it gluetun cat /tmp/gluetun/portsync_debug.logMethod B: Check on the HostIf you want to read the file via your host file share (e.g., /mnt/user/appdata/gluetun/scripts/portsync_debug.log), you MUST have completed Step 3.3 (Status File Path) correctly.Ensure the Container Path for that mapping is exactly /tmp/gluetun.If that mapping is missing, the log file exists inside the Gluetun container (Method A) but won't show up in your appdata folder.WARNING: Debug logs may contain your passwords in plain text (inside curl commands). Always set PORTSYNC_DEBUG back to false when you are done troubleshooting.Common Issues1. "qBittorrent not ready" TimeoutCause: qBittorrent takes longer than 5 minutes (300s) to start, or the script cannot reach the IP/Port.Fix: Check if PORTSYNC_QB_PORT matches your qBittorrent WebUI port. If your server is slow, increase PORTSYNC_TIMEOUT to 600.2. "Script finished with errors/warnings"**Cause: Usually incorrect credentials or a changed IP address.Fix: Check the container logs. If you see authentication errors, verify PORTSYNC_QB_USERNAME and PORTSYNC_QB_PASSWORD.3. Volatile Speeds / No Uploads**Symptoms: Downloads work (erratically), but upload speed is 0 B/s.Cause: This is rarely the script's fault. It is usually because qBittorrent is not bound to the correct VPN interface.Fix:1. Open qBittorrent WebUI.2. Go to Options (Preferences) -> Advanced.3. Look for Network Interface.4. Change it to tun0 (Do not leave it on "Any interface").5. Save and Restart qBittorrent.4. Console Color Bleeding* Issue: The "Running Version" line in the logs is colored Blue/Cyan when it shouldn't be.* Cause: A cosmetic issue with how the Gluetun logger wraps ANSI color codes.* Impact: Harmless. The script logic is unaffected.Screenshot of configurationCOMING SOON qBittorrent - Environment variables Unraid 6.12.14# Turn on Advanced view in templateWebUI: http://192.168.100.66:8080/ Extra Parameters: --net=container:GluetunVPN Network Type: None qBittorrent - Environment variables Unraid 7# Turn on Advanced view in templateWebUI: http://192.168.100.66:8080/ Network Type: ContainerContainer Network: GluetunVPN Chromium Environment variables Unraid 6.12.14WebUI: http://192.168.1.10:3000/Extra Parameters: --shm-size=1gb --net=container:GluetunVPN Network Type: None # Optional Config Type: PathName: Chormium Download Folder:Container /config/DownloadsHost Path: /mnt/user/downloads_array/chormium/Default Value:Access Mode: Read/WriteDescription: Specifies the directory for storing downloads made through the Chromium browser. By default, downloads are saved in /mnt/user/downloads_array/chromium/ on the host system. update_qbittorrent_listening_port.shSetup Gluetun qBittorrent Port Synchronization Script.pdf Edited May 16May 16 by Zerax Script Updated to version: 3.10
January 13, 20251 yr Great stuff!! I was just reading into this topic. There might be a better way to do this, with the help of the newly added environment variable that runs a script after port forwarding: https://github.com/qdm12/gluetun/pull/2399 The solutions towards the end of the PR are especially neat VPN_PORT_FORWARDING_UP_COMMAND=wget --retry-connrefused --tries=6 -qO- --post-data=json={\"listen_port\":{{PORTS}}} http://127.0.0.1:8080/api/v2/app/setPreferences
January 13, 20251 yr Author Thanks for bringing this up, @hallowatcher I wasn’t aware of the VPN_PORT_FORWARDING_UP_COMMAND variable before, but it looks like a great improvement for handling port updates directly. I’ll definitely look into this and see how I can incorporate it into my setup. Really appreciate you pointing this out! 🙌 Edited January 13, 20251 yr by Zerax
January 16, 20251 yr Author On 1/13/2025 at 9:28 PM, hallowatcher said: Great stuff!! I was just reading into this topic. There might be a better way to do this, with the help of the newly added environment variable that runs a script after port forwarding: https://github.com/qdm12/gluetun/pull/2399 The solutions towards the end of the PR are especially neat VPN_PORT_FORWARDING_UP_COMMAND=wget --retry-connrefused --tries=6 -qO- --post-data=json={\"listen_port\":{{PORTS}}} http://127.0.0.1:8080/api/v2/app/setPreferences I completely agree, the solutions in that PR are quite elegant, and it's great that the Gluetun project is evolving to make things more dynamic. That said, I ran into some hiccups with VPN_PORT_FORWARDING_UP_COMMAND=wget --retry-connrefused --tries=6 -qO- --post-data=json={\"listen_port\":{{PORTS}}} http://127.0.0.1:8080/api/v2/app/setPreferences. While it’s a clever approach, it didn't work out of the box for me either. So, I took the liberty of updating my script to fully embrace the new VPN_PORT_FORWARDING_UP_COMMAND environment variable. I’ve tested it to ensure it's not only functional but also ready for the upcoming Gluetun v3.40.0 release, where authentication is a must for /v1/openvpn/portforwarded. The flexibility of this variable is a game-changer, and I’m really looking forward to leveraging it more. If you’re trying out anything similar or need help tweaking the script, let me know—I’d love to collaborate further on this! Edited January 16, 20251 yr by Zerax
April 9, 20251 yr Thanks for the work on this. Setting up my first Unraid server and got it mostly working except this vpn port forwarding. It seems to be close. I verified port forwarding is working in the logs and can manually put that port number in qbittorrent. I verified the script is in /tmp/gluetun with x privileges but when I try to run I get a "/bin/sh: /tmp/gluetun/update_qbittorrent_listening_port.sh: not found" error. Any ideas?
April 10, 20251 yr Author 10 hours ago, JTVUS said: Thanks for the work on this. Setting up my first Unraid server and got it mostly working except this vpn port forwarding. It seems to be close. I verified port forwarding is working in the logs and can manually put that port number in qbittorrent. I verified the script is in /tmp/gluetun with x privileges but when I try to run I get a "/bin/sh: /tmp/gluetun/update_qbittorrent_listening_port.sh: not found" error. Any ideas? I updated the script. Please replace the update_qbittorrent_listening_port.sh file with the new version attached.Make sure to update your username and password in the script.Make sure it's executable (chmod +x /tmp/gluetun/update_qbittorrent_listening_port.sh).Run it again: /bin/sh -c /tmp/gluetun/update_qbittorrent_listening_port.sh Let me know if that helps or if you’re still running into issues! Edited November 26, 2025Nov 26 by Zerax
April 10, 20251 yr 3 hours ago, Zerax said: I updated the script. ... Let me know if that helps or if you’re still running into issues! That did it!! Thank you!
April 30, 20251 yr Does this also solve the qbit webui not being available through the gluetun container because the port forward got broken?
April 30, 20251 yr ? use qbit over deluge but a good setup video example on a pie connected to unraid could use a lxc / vm or run the compose on the unraid host...
May 23, 20251 yr This looks very interesting, but I'm stuck on one part.# Define a list of routes with the syntax "Http-Method /path" routes = ["GET /v1/openvpn/portforwarded"]I use AirVPN and my gluetun is set up with wireguard. I'm not sure what I have to use here instead. Could you help a newbie out?
August 15, 2025Aug 15 I tried setting up the Gluetun as "normal" with the linuxserver QBittorrent docker and every torrent I started would be status "stale"I found this:IMPORTANT PORT FORWARDING WITH PIA DOES NOT SEEM TO WORK!Would this fix this? - Portforwarding with PIA works in the "QBittorrentVPN docker"GitHubgluetun-wiki/setup/providers/private-internet-access.md a...Home to the Markdown Wiki page for Gluetun. Contribute to qdm12/gluetun-wiki development by creating an account on GitHub.
September 9, 2025Sep 9 HAs anyone gotten the gluetunvpn with the Qbittorrent working with PIA?I keep getting stale because port forwarding is a problem with Gluetunvpn.
September 9, 2025Sep 9 4 hours ago, casperse said:HAs anyone gotten the gluetunvpn with the Qbittorrent working with PIA?I keep getting stale because port forwarding is a problem with Gluetunvpn.yes...your gluten vpn needs the port forwards that qbit is using...
September 28, 2025Sep 28 This is a great script, your wiki was super clear! I had this working perfect and Qbittorent was showing "green", I then rebooted my server and now it's been stuck at "Connection status :Firewalled" since.Any advice on how to debug to see if the port updater isnt working? At least when I check the Gluetun logs I can see the reported port is being set correctly in the Qbit webui but even after waiting 15 minutes the icon doesn't update. I'm on a private tracker and really need to be able to seed.
September 29, 2025Sep 29 Author 10 hours ago, Swaino said:This is a great script, your wiki was super clear! I had this working perfect and Qbittorent was showing "green", I then rebooted my server and now it's been stuck at "Connection status :Firewalled" since.Any advice on how to debug to see if the port updater isnt working? At least when I check the Gluetun logs I can see the reported port is being set correctly in the Qbit webui but even after waiting 15 minutes the icon doesn't update. I'm on a private tracker and really need to be able to seed.Have you tried restarting the stack and watching the logs step by step? Here’s what I’d suggest for debugging:1. Restart Gluetun and immediately check its logs.2. Once Gluetun is fully up, restart qBittorrent.3. Look in the Gluetun logs for the port-forward script activity.If it’s working, you should see something like this:2025-09-29T06:12:05+02:00 INFO [port forwarding] qBittorrent is not available yet. Retrying in 5 seconds... 2025-09-29T06:12:10+02:00 INFO [port forwarding] qBittorrent is available. Proceeding with the script... 2025-09-29T06:12:10+02:00 INFO [port forwarding] Fetching listening port from Gluetun URL: http://127.0.0.1:8000/v1/openvpn/portforwarded 2025-09-29T06:12:10+02:00 INFO [http server] 200 GET /portforwarded wrote 15B to 127.0.0.1:50874 in 47.831µs 2025-09-29T06:12:10+02:00 INFO [port forwarding] Curl exit code: 0 2025-09-29T06:12:10+02:00 INFO [port forwarding] Raw Gluetun Response: [{"port":24219}] 2025-09-29T06:12:11+02:00 INFO [port forwarding] Fetched listening port: 24219 2025-09-29T06:12:11+02:00 INFO [port forwarding] Logging in to qBittorrent... 2025-09-29T06:12:11+02:00 INFO [port forwarding] Login successful. SID: 4lbXv5gN3XvB7VpngEg6LqQPt1T+Pdxt 2025-09-29T06:12:11+02:00 INFO [port forwarding] Updating listening port in qBittorrent to 24219... 2025-09-29T06:12:11+02:00 INFO [port forwarding] qBittorrent listening port updated successfully to 24219. 2025-09-29T06:12:11+02:00 INFO [port forwarding] Logging out from qBittorrent... 2025-09-29T06:12:11+02:00 INFO [port forwarding] Logout successful. 2025-09-29T06:12:11+02:00 INFO [port forwarding] Script finished.If the script fails to update after 10 retries, it will time out and qBittorrent’s port will not be updated. That usually means qBittorrent wasn’t ready, credentials were wrong, or the WebUI wasn’t reachable.Once the logs confirm the port was updated, open qBittorrent → Options → Connection and check that the “Listening Port” matches what Gluetun reported.If qBittorrent shows the correct port but still reports “firewalled,” try an external port test (from another device or a port-checking site) to confirm whether it’s actually open.Further troubleshooting with Gluetun firewall: - The Gluetun container has a built-in firewall which can sometimes block port forwarding. - You can temporarily disable it for debugging: FIREWALL=off- Enable detailed firewall logging to see all related commands: FIREWALL_DEBUG=on - These settings help verify whether Gluetun’s firewall is blocking the port. > ⚠️ Remember: disable the firewall for debugging **only** — re-enable it afterwards for security. Tracker-side delay: Some private trackers take several minutes to re-test your port after a reconnect. The status may show “firewalled” even though the port is already open. Check with a Torrent Tracker IP Checker Edited September 29, 2025Sep 29 by Zerax
September 29, 2025Sep 29 Author On 9/9/2025 at 2:21 PM, casperse said:HAs anyone gotten the gluetunvpn with the Qbittorrent working with PIA?I keep getting stale because port forwarding is a problem with Gluetunvpn.Yes. I’m using PIA with Gluetun + qBittorrent, and it works fine. The script was originally written with PIA in mind, since PIA rotates the forwarded port every 14 days. That’s why the script automatically fetches the new port from Gluetun and updates qBittorrent — otherwise, you’ll hit “stale” ports when PIA rotates them. If you’re getting issues, I’d suggest: - Make sure you’re using a **PIA location that supports port forwarding** (e.g., CA Montreal, CA Toronto, etc.). - Restart Gluetun and check the logs — you should see the port-forwarding process happening. - Confirm in qBittorrent’s **Connection tab** that the “Listening Port” matches the one Gluetun reports. > Note: PIA rotates forwarded ports every 14 days. The script handles this automatically, but you may need to restart the stack.
November 24, 2025Nov 24 Hey @Zerax, thank you for this script. I appreciate all the details for setting it up.I recently started having issues with it. Not sure what might have changed, but now when the port forwarding script starts to run, I get the error:qBittorrent is available. Proceeding with the script... Fetching listening port from Gluetun with authentication... jq: parse error: Invalid numeric literal at line 1, column 3 Failed to extract listening port from Gluetun response. Exiting.I then saw you updated the script, so I used your new script from April 10th, and I get this response now when I try to run the script:/ # /bin/sh -c /tmp/gluetun/update_qbittorrent_listening_port.sh Script created by Unraid user Zerax (Reddit user u/Snowbreath) Checking for required tools (curl and jq)... curl is already installed. jq is already installed. Waiting for qBittorrent to be available at http://127.0.0.1:8080... qBittorrent is available. Proceeding with the script... Fetching listening port from Gluetun URL: http://127.0.0.1:8000/v1/openvpn/portforwarded Curl exit code: 0 Raw Gluetun Response: [<a href="/v1/portforward">Moved Permanently</a>.] jq: parse error: Invalid numeric literal at line 1, column 3 Failed to parse valid port number from Gluetun response using jq. JQ Input (Raw Gluetun Response): [<a href="/v1/portforward">Moved Permanently</a>.] JQ Output (Attempted Port): [] / # Any idea what might be going on? If it is obvious, I apologize, I'm a bit of a noob at this stuff as much as I try to stumble my way through it 😅
November 25, 2025Nov 25 Author 17 hours ago, bigsteve said:Hey @Zerax, thank you for this script. I appreciate all the details for setting it up.I recently started having issues with it. Not sure what might have changed, but now when the port forwarding script starts to run, I get the error:qBittorrent is available. Proceeding with the script... Fetching listening port from Gluetun with authentication... jq: parse error: Invalid numeric literal at line 1, column 3 Failed to extract listening port from Gluetun response. Exiting.I then saw you updated the script, so I used your new script from April 10th, and I get this response now when I try to run the script:/ # /bin/sh -c /tmp/gluetun/update_qbittorrent_listening_port.sh Script created by Unraid user Zerax (Reddit user u/Snowbreath) Checking for required tools (curl and jq)... curl is already installed. jq is already installed. Waiting for qBittorrent to be available at http://127.0.0.1:8080... qBittorrent is available. Proceeding with the script... Fetching listening port from Gluetun URL: http://127.0.0.1:8000/v1/openvpn/portforwarded Curl exit code: 0 Raw Gluetun Response: [<a href="/v1/portforward">Moved Permanently</a>.] jq: parse error: Invalid numeric literal at line 1, column 3 Failed to parse valid port number from Gluetun response using jq. JQ Input (Raw Gluetun Response): [<a href="/v1/portforward">Moved Permanently</a>.] JQ Output (Attempted Port): [] / # Any idea what might be going on? If it is obvious, I apologize, I'm a bit of a noob at this stuff as much as I try to stumble my way through it 😅Thanks for pointing this out! I’ve got a newly fixed script ready, but I need to rewrite the whole install process to match the changes. Give me about an hour and I’ll have the updated guide posted.
November 26, 2025Nov 26 Author Hi @bigsteve , the script is now updated! Please let me know how it behaves on your end. Also, could you let me know which VPN provider you’re using?
December 5, 2025Dec 5 On 11/26/2025 at 2:45 AM, Zerax said:Hi @bigsteve , the script is now updated! Please let me know how it behaves on your end. Also, could you let me know which VPN provider you’re using?Hey! Sorry, I totally missed this reply. I'm using ProtonVPN and the new script appears to be working great! I got it set up with no issues. Thanks a bunch for sharing the update!
December 26, 2025Dec 26 Really appreciate you sharing this, it is a great guide.I'm finding a few things that don't seem quite right, and I am hoping you (or someone) might be able to help.Despite being in debug mode ( PORTSYNC_DEBUG: true), no log file is found.I am finding slightly faster speeds than I had on Mullvad, but the download speed is much more volatile, wildly swinging up and down, even between the update port executions (assuming that should cause some interruption).There is no upload.Some feedback on the guide I hope might be useful:"Step 3. Add Environment Variables" adds variables that are already included in Gluetun. Is this intentional? If not, perhaps you could tweak the naming, to make clear they're different? Else, rather than "add" variables, the section is for defining variables?"Step 4: Script Configuration", I initially read this as setting the values of existing properties, but when I couldnt find elements with the same name in the Gluetun container I assumed I needed to add them. Perhaps specify that they also need to be added?
December 27, 2025Dec 27 Author On 12/26/2025 at 1:29 PM, snayff said:Really appreciate you sharing this, it is a great guide.I'm finding a few things that don't seem quite right, and I am hoping you (or someone) might be able to help.Despite being in debug mode ( PORTSYNC_DEBUG: true), no log file is found.I am finding slightly faster speeds than I had on Mullvad, but the download speed is much more volatile, wildly swinging up and down, even between the update port executions (assuming that should cause some interruption).There is no upload.Some feedback on the guide I hope might be useful:"Step 3. Add Environment Variables" adds variables that are already included in Gluetun. Is this intentional? If not, perhaps you could tweak the naming, to make clear they're different? Else, rather than "add" variables, the section is for defining variables?"Step 4: Script Configuration", I initially read this as setting the values of existing properties, but when I couldnt find elements with the same name in the Gluetun container I assumed I needed to add them. Perhaps specify that they also need to be added?Thanks for the great feedback! I really appreciate you taking the time to point out those confusing spots.I have updated the Wiki based on your suggestions:Variable Confusion (Steps 3 & 4): You were absolutely right—the distinction between "editing existing template variables" and "adding new custom variables" wasn't clear. I’ve renamed the sections to "Configure Standard Gluetun Variables" and "Add Custom Script Variables" with specific notes on when to Edit vs. Add.Missing Log File: I suspect the log file wasn't showing up for you on the host because the /tmp/gluetun path mapping (Step 3.3) might have been missed or configured differently. I’ve updated the Troubleshooting section to explicitly state that the script runs inside Gluetun (not qBittorrent) and added two methods to find the logs: one via docker exec (guaranteed to work) and one via the Host path.Volatile Speeds / No Upload: This is usually a binding issue rather than the script itself. I’ve added a troubleshooting tip to ensure qBittorrent's Network Interface is bound specifically to tun0 rather than "Any interface," which fixes the zero-upload issue for most users.Thanks again for helping improve the guide! Let me know if the updated version is clearer.
April 15Apr 15 For qmcgaw/gluetun , there is a variable VPN_PORT_FORWARDING_STATUS_FILE, you need to set this one to "/gluetun/scripts/forwarded_port", otherwise it will generate the port file in the wrong folder and you will get a warning about a non existent file in the log.Aside from that it seems to work just fine. 👍
May 16May 16 HiThe script can not login anymore with the last version of qbittorent.Am I the only one having this problem?Unraid 7.2.6qB : 5.2.0 Edited May 16May 16 by deadnote
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.