Django Failed to establish a new connection <urllib3.connection.HTTPSConnection>

hello, I use Django 2.2 and I have an api that is connected to two Esx servers.

  • a =
  • b =

everything works perfectly, except that during my test when I add a third fake server, it tells me that the server does not respond because connection time out. So the error is handled and I don’t have a yellow page from Django.

Except when enter fourth server this time private ip like I have an error Max retries exceeded NewConnectionError(<urllib3.connection.HTTPSConnection’>

But when I use a public IP like, I don’t get any error.

What I would like is to handle the error better when someone enters a private IP.

what’s weird is that on local env localhost everything works even with private ip but when I am in my test server it doesn’t work.

My full traceback
Here is my file.

import requests
import os
import json
from requests.packages.urllib3.exceptions import InsecureRequestWarning

os.environ['REQUESTS_CA_BUNDLE'] = os.path.join('/etc/ssl/certs/')
req = requests.Session()
req.verify = False

class VmwareApi:
    def __init__(self):
        self.ip = ""
        self.user = ""
        self.password = ""
        self.arg1 = "" = ""
        self.params = ""

    def session(self):
            a ='https://' + self.ip + '/api/session',
                         auth=(self.user, self.password),
                         timeout=1, verify=False)
   = str(a.json())
        except requests.exceptions.Timeout:
            return 'ConnectTimeoutError'
        return req

    def param_loader(self):
        if self.params:
            self.params = json.loads(self.params)

    def vapirequestget(self):
            myreq = req.get('https://' + self.ip + self.arg1,
                            params=self.params, verify=False,
            return myreq
        except requests.exceptions.Timeout:
            return 'ConnectTimeoutError'