Select to view content in your preferred language

Use Python-API behind Proxy

06-13-2017 05:47 AM
New Contributor III

I'm trying to use the new Python-API with our on-premise system. Our company runs it's own public key infrastructure, so I've configured Portal for ArcGIS with a corresponding certificate. Furthermore, there is a company-wide proxy that we are using.

As a first throw, I'd like to connect to ArcGIS Online by doing this:

from arcgis.gis import GIS
my_gis = GIS()

This crashes with:

c:\Program Files\ArcGIS\Pro\bin\Python>python.exe "C:\temp\"
Traceback (most recent call last):
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 1254
, in do_open
 h.request(req.get_method(), req.selector,, headers)
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 1106, i
n request
 self._send_request(method, url, body, headers)
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 1151, i
n _send_request
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 1102, i
n endheaders
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 934, in
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 877, in
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 1252, i
n connect
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 853, in
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\http\", line 832, in
OSError: Tunnel connection failed: 407 authenticationrequired

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "C:\temp\", line 7, in <module>
 my_gis = GIS()
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\",
 line 95, in __init__
 verify_cert=self._verify_cert, client_id=self._client_id)
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\_impl\po", line 160, in __init__
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\_impl\co", line 281, in __init__
 self.login(username, password, expiration, client_id)
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\_impl\co", line 504, in login
 resp ='', { 'f': 'json' }, add_token=False) # probe portal to fin
d auth scheme
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\site-packages\arcgis\_impl\co", line 1031, in post
 resp =, data=encoded_postdata.encode())
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 466,
 in open
 response = self._open(req, data)
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 484,
 in _open
 '_open', req)
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 444,
 in _call_chain
 result = func(*args)
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 1297
, in https_open
 context=self._context, check_hostname=self._check_hostname)
 File "c:\Program Files\ArcGIS\Pro\bin\Python\lib\urllib\", line 1256
, in do_open
 raise URLError(err)
urllib.error.URLError: <urlopen error Tunnel connection failed: 407 authenticati

Is it related to some proxy issues and if yes, where do I have to configure the proxy?

Tags (2)
27 Replies
New Contributor III

After configuring everything from scratch, I ended up with this: urllib.error.URLError: <urlopen error [WinError 10061]

A bit of searching the web confirms my suspicion that it is related to the proxy. Our proxy requires authentication and urlopen should actually consider Windows' proxy settings (configured within Internet Explorer), but it doesn't seem to work.

I've also tested whether the environment variables http_proxy or https_proxy make any difference - nope

So any help would be appreciated!

New Contributor III

I am also struggling with this, there is no documentation related to configuring proxy settings, ESRI please publish this.

Esri Contributor

The Python API currently doesn't support proxies. We will be adding this support to the next release (release data TBD). Till then, can you see if you can use the workaround at  The lazy Flimbot: Using ArcGIS API for Python (1.0.1) behind a proxy ?

New Contributor II

do you know the next release date? we need the proxy support.


Esri Contributor

We released v1.2.3 with support for proxy servers on Friday.

In addition to explicitly named variable, the GIS object supports optional key word

================    ===============================================================
**kwargs**          **Description**
----------------    ---------------------------------------------------------------
proxy_host          optional string, host name of the proxy server
----------------    ---------------------------------------------------------------
proxy_port          optional integer, proxy host port.  The default is 80.
================    ===============================================================

Usage Example: Anonymous ArcGIS Online Login with Proxy

gis = GIS(proxy_host='', proxy_port=8888)
New Contributor II


thanks for your answer.

But the new version is not available on


0 Kudos
Esri Contributor

It is available on the esri conda channel - Files :: Anaconda Cloud 

We'll be updating the developer site later this month.

MVP Emeritus

rsingh-esristaff ,

I used

conda upgrade -c esri arcgis

in the Anaconda Prompt window (today) based on the instructions in  and it looks like is grabbed the 1.2.3 release. 

Does the above command grab from the esri conda channel ?  And if is does, will it always grab a "ready for release" version and not a preliminary release?

Note: I found using the command line has worked better than trying to do the upgrade thru Pro...however, I may be doing that incorrectly or mixing apples with oranges.  However, the above command is very straight forward for me.

0 Kudos
Esri Contributor

The command

conda upgrade -c esri arcgis

grabs from the esri conda channel and it will always grab the latest released version. It will not get a preliminary version.

In this command "-c esri" specifies that it should use the esri conda channel.

If you wish you upgrade to a specific version you can specify it as:

conda upgrade -c esri arcgis=1.2.0