Unable to connect to ArcGIS Enterprise Portal via python

11-15-2020 03:17 AM
New Contributor II

Hello all,

I am trying to make a connection to our secured Portal using the following code of ArcGIS API for Python:



from arcgis.gis import GIS
gis = GIS(portal, user, password)



I use ArcGIS Pro 2.4.2 with Python 3.6.8. The authentication schemes used with our portal is the Built-in users
I succeed in connecting to arcgis online.

Following the error message :

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 334, in __init__
raise e
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 322, in __init__
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\portalpy.py", line 163, in __init__
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\connection.py", line 308, in __init__
self.login(username, password, expiration, client_id)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\connection.py", line 554, in login
resp = self.post('', { 'f': 'json' }, add_token=False) # probe portal to find auth scheme
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\connection.py", line 1125, in post
resp = opener.open(url, data=encoded_postdata.encode())
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 532, in open
response = meth(req, response)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 570, in error
return self._call_chain(*args)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\urllib\request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable

Thank you for your help,


0 Kudos
7 Replies
MVP Frequent Contributor

Looks like your URL could be wrong.

Something like

portal = r"https://dave.geo.com/portal/home"

New Contributor II

Thanks for your answer. I tried to use your solution and same error... Could this be a certificate problem ? Our portal is installed on a very secured network.

Or maybe a conflict with another application ? ( I recently installed QGIS 3)
This worked as expected with a previous version of ArcGIS pro (but without any QGIS installed)


0 Kudos
MVP Esteemed Contributor

It is highly unlikely that having QGIS and Pro on the same machine makes a difference.

HTTP 503 errors usually indicate something is going on with the server and not the client.  Since you have done this in the past and it worked, it may be something is partially broken with your on-premises Portal.  I would contact the group that manages it.

New Contributor II

Thanks for your answer.
The weird thing is that logging in to our portal using ArcGIS Pro works as expected. I managed to publish and update the hosted feature layers without any issues. Likewise, I manage to use the rest API with Firefox.


0 Kudos
MVP Frequent Contributor

There's some certificate/PKI stuff you can specify also in GIS(..



but well out of my depth there, good luck!

0 Kudos
New Contributor II

Thanks David for your help but I have already tested this solution without any success 😞

0 Kudos
New Contributor II

Didn't find a solution yet but this seems to work as expected with the previous version of arcgis pro python library. I'am waiting for the next version.

0 Kudos