OSError: Tunnel connection failed: 407 Proxy Authorization Required

Last Published: September 25, 2020

Error Message

Attempts to run a Python script and log in to Portal for ArcGIS fail, and return the following error:

OSError: Tunnel connection failed: 407 Proxy Authorization Required

The following shows a sample code that may result in the error:

import arcgis

con = arcgis.gis.GIS(url="", username="user1")


There are two possible causes:

  • The connection to the selected portal is blocked by the proxy on the network. This occurs if the connection uses a custom proxy, for example, a company public key infrastructure with corresponding certificates.
  • The script is unable to automatically recognize the proxy used by the Portal for ArcGIS and ArcGIS Server configured certificate.

Solution or Workaround

Use the following solutions to fix the issue:

Add the following ArcGIS Online domains to the allowed list:

  • https://*
  • https://*
  • https://*
  • https://*

Declare the proxy_port parameter

To enable the script to recognize the custom port, the proxy_port parameter must be declared and added to the full script. The following shows the sample code:

  • For ArcGIS Online login:
gis = GIS(proxy_host='', proxy_port=8888)
  • For a secured proxy:
gis = GIS(url="", username="user1", password="password1", proxy_host="<username>:<password>@<proxyname>”, proxy_port=8888, verify_cert=False)

Article ID:000022198

  • ArcGIS Online
  • Portal for ArcGIS
  • ArcGIS Server
  • ArcGIS API for Python 1 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options