question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

az login: Failed to establish a new connection: [Errno -2] Name does not resolve

See original GitHub issue

This is autogenerated. Please review and update as needed.

Describe the bug

When logging in with azure cli inside of mcr.microsoft.com/azure-cli:2.32.0 container I get an error (See below), The same login command works if I login outside of the container on my host.

Command Name az login

Errors:

<urllib3.connection.HTTPSConnection object at 0x7f3ed60e6490>: Failed to establish a new connection: [Errno -2] Name does not resolve

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • Put any pre-requisite steps here…
  • az login --service-principal -u {} -p {} --tenant {}

Expected Behavior

Should have successfully signed in.

Environment Summary

Linux-5.4.0-99-generic-x86_64-with, Alpine Linux v3.14
Python 3.9.6
Installer: DOCKER

azure-cli 2.32.0 *

Additional Context

Running inside a mcr.microsoft.com/azure-cli:2.32.0 container

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
baromojmcommented, Jun 23, 2022

The issue seems to be with URL from inside docker only: https://management.azure.com/tenants?api-version=2019-11-01

Steps to reproduce: $ docker run -it --rm mcr.microsoft.com/azure-cli:latest bash-5.1# curl https://management.azure.com/tenants?api-version=2019-11-01 curl: (6) Could not resolve host: management.azure.com

Same command from outside docker works fine: $ curl https://management.azure.com/tenants?api-version=2019-11-01 {“error”:{“code”:“AuthenticationFailed”,“message”:“Authentication failed. The ‘Authorization’ header is missing.”}}

DNS resolution fails, but only from inside docker (outside docker works fine):

bash-5.1# cat /etc/resolv.conf
nameserver 10.0.2.3
nameserver 172.30.240.1
bash-5.1# nslookup management.azure.com 172.30.240.1
Server:         172.30.240.1
Address:        172.30.240.1:53

Non-authoritative answer:
*** Can't find management.azure.com: Parse error

Non-authoritative answer:
*** Can't find management.azure.com: Parse error
bash-5.1# nslookup management.azure.com 10.0.2.3
Server:         10.0.2.3
Address:        10.0.2.3:53

Non-authoritative answer:
*** Can't find management.azure.com: Parse error

Non-authoritative answer:
*** Can't find management.azure.com: Parse error
0reactions
Al77056commented, Nov 14, 2022

I ran into the same issue, and found out a workaround by adding the “–add-host=management.azure.com:20.40.227.150” to the docker command line.

Read more comments on GitHub >

github_iconTop Results From Across the Web

az login error- Failed to establish a new connection: [Errno -2 ...
I checked that I am able to resolve other external as well as internal url's without any problem. The problem so far seems...
Read more >
Az login urllib3 [Errno 11001] getaddrinfo failed - Stack Overflow
This error will occur due to proxy (Internal Proxy or Corporate Proxy). ... I am trying to log into Azure on Powershell using...
Read more >
How to view the tags key/value in a blob using login as ...
HTTPSConnection object at 0x7fb0eb30e200>: Failed to establish a new connection: [Errno -2] Name or service not known. Run the command a) az ......
Read more >
Connection problems - doing CLI for Azure DevOps
How to fix connection problems · In addition to logging in through az devops login , make sure you are logged in to...
Read more >
Name or service not known error appears when opening an ...
The same happens with the OOB Portal and any OAuth 2.0 event. Resolution. Ensure to add a record for the DNS name on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found