Setting up az cli, however I cannot connect due to max retries failed, target host refused the connection. How can I get past my proxy in Windows?

Viewed 1284

I've followed Microsoft's instructions for "Proxy Blocks a Connection", which reads:

(New-Object System.Net.WebClient).Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

...however I'm still receiving the following error when attempting to do az login or az extension add --name azure-devops:

Please ensure you have network connection. Error detail: HTTPSConnectionPool(host='aka.ms', port=443): Max retries exceeded with url: /azure-cli-extension-index-v1 (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0448E9F0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',)))

I'm trying to connect to our company's Org on dev.azure.com. I've searched and have not come across anything that helps.

Thanks - please let me know if there is more info that's needed. I know the address & port of my proxy, (http/s://proxy.{env}.{org}.com:{PORT}), however I don't see a way to explicitly state this, or if it would even work.

TIA

1 Answers

Refer

Depending on whether you use cmd or bash, set the HTTP_PROXY or HTTPS_PROXY environment variable as below:

CMD:

rem Non-authenticated HTTP server:
set HTTP_PROXY=http://{proxy host}:{port}

rem Authenticated HTTP server:
set HTTP_PROXY=http://username:password@{proxy host}:{port}

rem Non-authenticated HTTPS server:
set HTTPS_PROXY=http://{proxy host}:{port}

rem Authenticated HTTPS server:
set HTTPS_PROXY=http://username:password@{proxy host}:{port}

Bash:

# Non-authenticated HTTP server:
HTTP_PROXY=http://{proxy host}:{port}

# Authenticated HTTP server:
HTTP_PROXY=http://username:password@{proxy host}:{port}

# Non-authenticated HTTPS server:
HTTPS_PROXY=http://{proxy host}:{port}

# Authenticated HTTPS server:
HTTPS_PROXY=http://username:password@{proxy host}:{port}
Related