Jenkins returns HTTPError 503 to Python script

Hello everyone,
I have the following problem:
from a Python script I make a call to Jenkins to execute a Job:
resp = requests.post(url, data=data, auth=(username, password))
resp.raise_for_status()

In most cases everything works correctly but sometimes it happens that raise_for_status returns me the error:
requests.exceptions.HTTPError: 503 Server Error: Proxy Error for url: https://jenkins

In all the cases so far, the pipeline on Jenkins started correctly but the Python script failed me because it received back that error 503

Has this ever happened to you guys?