HTTP Error 500 when connecting to portal

07-18-2017 02:47 PM
New Contributor

I am able to connect to ArcGIS online, but when we try to connect directly to our portal we receive the following error information. I am new to administering portal and not sure what i could be missing.

from arcgis.gis import GIS

gis = GIS("", "username", "password")


HTTPError                                 Traceback (most recent call last)

<ipython-input-14-297762dcb9de> in <module>()

      1 from arcgis.gis import GIS

----> 2 gis = GIS("", "username")


C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\arcgis\gis\ in __init__(self, url, username, password, key_file, cert_file, verify_cert, set_active, client_id, profile)

    144         self._datastores_list = None

    145         self._portal = portalpy.Portal(self._url, self._username, self._password, self._key_file, self._cert_file,

--> 146                                        verify_cert=self._verify_cert, client_id=self._client_id)

    147         if url.lower().find("") > -1 and \

    148            self._portal.is_logged_in:


C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\arcgis\_impl\ in __init__(self, url, username, password, key_file, cert_file, expiration, referer, proxy_host, proxy_port, connection, workdir, tokenurl, verify_cert, client_id)

    161                                              proxy_port=proxy_port,

    162                                              verify_cert=verify_cert,

--> 163                                              client_id=client_id)

    164         #self.get_version(True)

    165         self.get_properties(True)


C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\arcgis\_impl\ in __init__(self, baseurl, tokenurl, username, password, key_file, cert_file, expiration, all_ssl, referer, proxy_host, proxy_port, connection, verify_cert, client_id)


    280         if cert_file is None and key_file is None:

--> 281             self.login(username, password, expiration, client_id)


    283     #----------------------------------------------------------------------


C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\arcgis\_impl\ in login(self, username, password, expiration, client_id)

    505                     self._token = newtoken


--> 507             resp ='', { 'f': 'json' }, add_token=False) # probe portal to find auth scheme

    508                                                   # if basic, digest, NTLM or Kerberos, etc is being used

    509                                                   # except handler will catch it and set self._auth appropriately


C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site-packages\arcgis\_impl\ in post(self, path, postdata, files, ssl, compress, is_retry, use_ordered_dict, add_token, verify_cert, token, try_json, out_folder, file_name, force_bytes, add_headers)

   1036             opener.addheaders = headers

   1037             #print("***"+url)

-> 1038             resp =, data=encoded_postdata.encode())

   1039             resp_data, is_file = self._process_response(resp,

   1040                                                out_folder=out_folder,


C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\urllib\ in open(self, fullurl, data, timeout)

    530         for processor in self.process_response.get(protocol, []):

    531             meth = getattr(processor, meth_name)

--> 532             response = meth(req, response)


    534         return response


C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\urllib\ in http_response(self, request, response)

    640         if not (200 <= code < 300):

    641             response = self.parent.error(

--> 642                 'http', request, response, code, msg, hdrs)


    644         return response


C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\urllib\ in error(self, proto, *args)

    568         if http_err:

    569             args = (dict, 'default', 'http_error_default') + orig_args

--> 570             return self._call_chain(*args)


    572 # XXX probably also want an abstract factory that knows when it makes


C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\urllib\ in _call_chain(self, chain, kind, meth_name, *args)

    502         for handler in handlers:

    503             func = getattr(handler, meth_name)

--> 504             result = func(*args)

    505             if result is not None:

    506                 return result


C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\urllib\ in http_error_default(self, req, fp, code, msg, hdrs)

    648 class HTTPDefaultErrorHandler(BaseHandler):

    649     def http_error_default(self, req, fp, code, msg, hdrs):

--> 650         raise HTTPError(req.full_url, code, msg, hdrs, fp)


    652 class HTTPRedirectHandler(BaseHandler):


HTTPError: HTTP Error 500: Internal Server Error

0 Kudos
1 Reply
New Contributor III

Hello  Christopher Clary,

I had the same issue before when connecting to my local portal and the issue was that my portal dosn't have a trusted ceritifcate installed , and to be able to connect through the API I just made set the verify certificate paramter to false and I was able to connect.

So you either need to install a certificate from trusted authority or you can escap certficate validation while connect to your portal by modify your code as the following:

gis = GIS("", "username", "password",verify_cert=False)

0 Kudos