How to fix az cannot connect to proxy on my Windows PC?

Peizhu S 20 Reputation points
2023-11-06T22:13:22.1666667+00:00

Hi,

I am a new user. After installed Azure CLI and added proxy environment variables, I tried "az login" in my Windows PC and got the following error: "Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')". I already include username:password in the environment variables. What else should I configure to make it work? Thank you!

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,996 questions
0 comments No comments
{count} votes

Accepted answer
  1. navba-MSFT 26,245 Reputation points Microsoft Employee
    2023-11-07T06:37:06.2133333+00:00

    @Peizhu S Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    I understand that you are encountering the error Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required') while using the Azure CLI.

    To make the Azure CLI work behind a proxy there are a few steps to be considered.

    To configure a proxy globally for your script or app, define HTTP_PROXY or HTTPS_PROXY environment variables with the server URL. These variables work with any version of the Azure libraries. Note that HTTPS_PROXY doesn't mean HTTPS proxy, but the proxy for https:// requests.

    If the proxies require authentication, The format of the HTTP_PROXY or HTTPS_PROXY environment variables should include the authentication, such as HTTPS_PROXY="https://username:password@proxy-server:port"

    # Non-authenticated HTTP proxy for HTTPS requests:
    
    export HTTPS_PROXY=http://10.10.1.10:1180
    
    # Authenticated HTTP proxy for HTTPS requests:
    
    export HTTPS_PROXY=http://username:password@10.10.1.10:1180
    
    # Non-authenticated HTTP proxy for HTTP requests:
    
    export HTTP_PROXY=http://10.10.1.10:1180
    
    # Authenticated HTTP proxy for HTTP requests:
    
    export HTTP_PROXY=http://username:password@10.10.1.10:1180  
      
    

    If the above steps doesn't help you need to raise the issue in the Azure CLI GitHub repo here:
    https://github.com/Azure/azure-cli/issues . The AzCLI experts will be able to assist you further.

    Hope this helps.

    **
    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.