About once every 1-7 days, authorization stops working on my PBS servers. client error (Connect)","status":400

Bl1c

Member
Aug 15, 2023
9
9
8
Ukraine
About once every 1-7 days, authorization stops working on my PBS servers.
If I try login, I have successfully receives HTTP request (hence HTTP 200 OK) but fails to connect to backend daemons.

I immediately get an error:
{"errors":{},"message":"client error (Connect)","status":400,"success":false}

After reboot server, the problem goes away.

I tried installing pbs 4.0-1 from scratch, but the problem persisted.

This problem is reproduced on two servers pbs 4.0-1. Before, pbs 2.4-7 was used, and it current worked.

ssh also stops working, but there are no errors in the logs except for:
proxmox-backup-proxy[16048]: POST /api2/json/access/ticket: 400 Bad Request: [client [::ffff:IP]:] client error (Connect)
 
As I found out, the error is caused by proxmox-backup.service.
Now I use this for auto fix. But that's not the solution.

Add script:
nano /usr/local/bin/pbs-autofix.sh

Code:
#!/bin/bash
# Proxmox Backup Server auto-diagnostic & self-healing script

LOGFILE="/var/log/pbs-autofix.log"
STATEFILE="/run/pbs-autofix.state"
DATE_CMD="/bin/date"

log() {
    echo "[$($DATE_CMD '+%Y-%m-%d %H:%M:%S')] $1" >> "$LOGFILE"
}

check_service() {
    systemctl is-active --quiet proxmox-backup.service
}

#---------------
if [ -f "$STATEFILE" ]; then
    PREV_STATE=$(cat "$STATEFILE")
else
    PREV_STATE="unknown"
fi

#-----------
if check_service; then
    CURRENT_STATE="ok"
else
    CURRENT_STATE="fail"
fi

#-------------
if [ "$CURRENT_STATE" != "$PREV_STATE" ]; then
    if [ "$CURRENT_STATE" = "fail" ]; then
        log "❌ proxmox-backup.service stopped. Restarting..."
        systemctl restart proxmox-backup.service
        sleep 5
        if check_service; then
            log "✅ proxmox-backup.service recovered successfully after restart."
            CURRENT_STATE="ok"
        else
            log " proxmox-backup.service still not running after restart!"
        fi
    elif [ "$CURRENT_STATE" = "ok" ]; then
        log "✅ proxmox-backup.service is active again."
    fi
fi

#------
echo "$CURRENT_STATE" > "$STATEFILE"

chmod +x /usr/local/bin/pbs-autofix.sh

Add to cron:
nano /etc/cron.d/pbs-autofix

Code:
*/5 * * * * root /usr/local/bin/pbs-autofix.sh

systemctl restart cron

watch logs:
less /var/log/pbs-autofix.log