title: Failed to establish a new connection: [Errno 11001] getaddrinfo failed' in Python 3.9
body: <p>This script is used to send data to a 3rd party. It seems to run fine when connected to any network other than my work network. When connected to my work network, it will run for a few minutes, PUT/POSTing as it should, and then suddenly the following error will appear:</p>
  <pre><code>  File &quot;C:\Users\user\AppData\Local\RPackages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connection.py&quot;, line 169, in _new_conn
      conn = connection.create_connection(
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\util\connection.py&quot;, line 73, in create_connection
      for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
    File &quot;C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\lib\socket.py&quot;, line 954, in getaddrinfo
      for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
  socket.gaierror: [Errno 11001] getaddrinfo failed
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py&quot;, line 699, in urlopen
      httplib_response = self._make_request(
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py&quot;, line 382, in _make_request
      self._validate_conn(conn)
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py&quot;, line 1010, in _validate_conn
      conn.connect()
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connection.py&quot;, line 353, in connect
      conn = self._new_conn()
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connection.py&quot;, line 181, in _new_conn
      raise NewConnectionError(
  urllib3.exceptions.NewConnectionError: &lt;urllib3.connection.HTTPSConnection object at 0x0000022FD9B44FA0&gt;: Failed to establish a new connection: [Errno 11001] getaddrinfo failed
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\adapters.py&quot;, line 439, in send
      resp = conn.urlopen(
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\connectionpool.py&quot;, line 755, in urlopen
      retries = retries.increment(
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\urllib3\util\retry.py&quot;, line 574, in increment
      raise MaxRetryError(_pool, url, error or ResponseError(cause))
  urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='vaccine-verify-v1.services.school.edu', port=443): Max retries exceeded with url: /api/verify (Caused by NewConnectionError('&lt;urllib3.connection.HTTPSConnection object at 0x0000022FD9B44FA0&gt;: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;C:\scripture\bali_vax.py&quot;, line 71, in &lt;module&gt;
      post_vax_record(row)
    File &quot;C:\scripture\bali_vax.py&quot;, line 38, in post_vax_record
      response = requests.post(url,json=vaxrecord, headers=headers, timeout=5)
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\api.py&quot;, line 117, in post
      return request('post', url, data=data, json=json, **kwargs)
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\api.py&quot;, line 61, in request
      return session.request(method=method, url=url, **kwargs)
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py&quot;, line 542, in request
      resp = self.send(prep, **send_kwargs)
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py&quot;, line 655, in send
      r = adapter.send(request, **kwargs)
    File &quot;C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\adapters.py&quot;, line 516, in send
      raise ConnectionError(e, request=request)
  requests.exceptions.ConnectionError: HTTPSConnectionPool(host='vaccine-verify-v1.services.school.edu', port=443): Max retries exceeded with url: /api/verify (Caused by NewConnectionError('&lt;urllib3.connection.HTTPSConnection object at 0x0000022FD9B44FA0&gt;: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
  
  </code></pre>
  <p>Script</p>
  <pre><code>import timeit
  start = timeit.default_timer() 
  
  import requests
  
  url = 'https://vaccine-verify-v1.services.school.edu/api/verify' 
  client_id = &quot;abc&quot;
  client_secret = &quot;123&quot;
  
  def post_vax_record(record):
      manuallyVerified = record[7].lower() == &quot;true&quot;; 
      vaxrecord = { &quot;firstName&quot;:record[0], &quot;lastName&quot;: record[1], &quot;dob&quot;: record[2], &quot;phoneNumber&quot;: (record[3] or '4444444444'), &quot;state&quot;: record[4], &quot;zip&quot;: record[5][:5], &quot;campusName&quot;: &quot;Baltimore&quot;, &quot;instituitionId&quot;: 0, &quot;campusSuCd&quot;: 28, &quot;sunyLanId&quot;: record[6], &quot;sunyStudId&quot;: 0, &quot;ssoId&quot;: &quot;BEL-&quot;+record[6], &quot;manuallyVerified&quot;: manuallyVerified }
      headers = {'Client_Id':client_id, 'Client_Secret':client_secret,'Content-Type':'application/json'}
      response = requests.post(url,json=vaxrecord, headers=headers, timeout=5)
      if response:
  
          json_response = response.json()
          if ('message' in json_response and json_response['message'] ==  'The Student record already exists. Please use put operation to insert the record.'): #changed from update to insert
              print ('Post failed. Trying put instead')
              response = requests.put(url,json=vaxrecord, headers=headers)
              if response:
                  print('Success on put for '+record[6])
              else:
                  print('Put failed for '+record[6])
          else: 
              print('Success on post for '+record[6])
          print(response.json())  
      else:
          print('Post failed for '+record[6]+' with error code: ')
          print(response.status_code)
          
  import csv
  with open('data_file.csv') as csvDataFile:
      csvReader = csv.reader(csvDataFile)
      for row in csvReader:
          if row[6].upper().split('@')[1] in (&quot;LIVE.LODI.EDU&quot;, &quot;LODI.EDU&quot;): 
            if row[0].upper() != &quot;FIRSTNAME&quot;:
              row[6] = row[6].upper().split('@')[0]
              post_vax_record(row)
          else:
              print('NON-LODI EMAIL FOUND FOR '+row[1]+', '+row[0]+'. WILL NOT PROCESS RECORD!')
  stop = timeit.default_timer()
  print('Run Time: ', stop - start)
  </code></pre>
  <p>While testing this script, and using smaller CSVs (with less records to read in), I never had an issue. Just recently has this been occurring. Any help is greatly appreciated.</p>
  <p>Thank you.</p>