Jump to content
Not connected, Your IP: 216.73.216.63
Blatantly0156

ANSWERED Gluetun: Port forwarding works for an hour

Recommended Posts

I'm running into an issue here, and I'm not sure where to start exactly.
The problem is probably not new, it's only that I didn't notice it before.

Here's my setup:
Proxmox > Debian > Docker > Gluetun > Multiple Qbittorrent instances
Qbittorrents are routed through gluetun.

I noticed I didn't get much upload, although I'm seeding a lot and was looking into the problem. I tested if ports were open on the dashboard here and it said Connection Refused (111).
I did some troubleshooting which got me to restart the stack of gluetun and qbittorrents. I checked if ports are open: Yes! (I didn't change anything in the config by the way)

Yay, Problem solved I thought.

Only after a couple days, the same error: Connection Refused.

I tested again now and the same thing happened after an hour or so.

Any ideas?

Here's docker-compose and gluetun logs:
https://pastebin.com/g7xw5E2R

It looks like a firewall issue of some kind, but there's no firewall running on the debian system. Maybe it's a gluetun issue, but I want to ask here as well

Thanks in advance


 

Share this post


Link to post
Posted ... (edited)

Thanks for the fast reply! I will look into it.

EDIT:
For future readers: the link above was exactly my problem. I fixed by delaying the health check to 2 minutes. Apparently this is used for OpenVPN only anyway. Since I use Wireguard it doesn't matter.
I added the following line to the environment in the gluetun docker-compose. 12 hours it's still running perfectly.

HEALTH_VPN_DURATION_INITIAL=120s

 

Edited ... by Blatantly0156
added my solution

Share this post


Link to post
Posted ... (edited)

It seems the healthcheck solution would be better though.
 

healthcheck:
    test: ["CMD-SHELL", "wget -qO- http://portcheck.transmissionbt.com/4330 | grep -q 1 || exit 1"]
    interval: 1m30s
    timeout: 10s
    retries: 3
    start_period: 40s


 

Edited ... by Gliglue

Share this post


Link to post

You could also run a script to check if the port is open, and if it's not restart the stack, then notify you via webhook.

Create a script file, put the below code in it (modify the CONFIGURATION section for your environment), make the file executable, then put it on a cron schedule (I check mine every 15 minutes, been running like this for a few months). I use Cronicle as my cron scheduler (it's nice using a single application to manage scheduling for multiple servers), but you could use crontab if you want simplicity.
 

#!/bin/sh

# CONFIGURATION
GLUETUN_CONTAINER="gluetun"
FORWARDED_PORT=YourForwardedPort
COMPOSE_DIR="/your/gluetun/docker/compose/directory"
WEBHOOK_URL="https://discord.com/api/webhooks/yourDiscordChannelWebhook"

# Get current VPN IP from inside the container using wget
VPN_IP=$(docker exec "$GLUETUN_CONTAINER" wget -qO- https://ipinfo.io/ip)

# Verify that we got an IP
if [ -z "$VPN_IP" ]; then
    echo "$(date) - ERROR: Could not retrieve VPN IP from container $GLUETUN_CONTAINER." >&2
    exit 1
fi

# Check if port is open using nc, suppressing nc's own output
if nc -z -w3 "$VPN_IP" "$FORWARDED_PORT" >/dev/null 2>&1; then
    echo "$(date) - Port $FORWARDED_PORT on $VPN_IP is open and reachable."
else
    echo "$(date) - Port $FORWARDED_PORT on $VPN_IP is closed. Restarting stack..."
    cd "$COMPOSE_DIR"
    docker compose down
    sleep 5
    docker compose up -d

    # Notify via Webhook about the restart
    curl -X POST -H "Content-Type: application/json" \
        -d '{"content":"VPN port forwarding failed. Gluetun stack restarted to repair the issue."}' \
        "$WEBHOOK_URL"

    echo "$(date) - Stack restarted in $COMPOSE_DIR due to port $FORWARDED_PORT being closed."
fi

Share this post


Link to post

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Security Check
    Play CAPTCHA Audio
    Refresh Image

×
×
  • Create New...