azure-cli: az login hangs forever, redirects to localhost and hits ERR_CONNECTION_REFUSED in browser

This is autogenerated. Please review and update as needed.

Describe the bug

az login hangs forever

  1. Run az login
  2. Browser window opens where I select which account I want to sign in to
  3. The redirect goes to the browser in a new tab which looks like http://localhost:34541/?code=REDACTED&client_info=REDACTED&state=REDACTED&session_state=REDACTED

Command Name az login

Errors: Sign in hangs forever and never finishes

To Reproduce:

Attempt to sign in

Expected Behavior

Sign in succeeds

Environment Summary

Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-glibc2.31, Ubuntu 20.04.6 LTS
Python 3.10.10
Installer: DEB

azure-cli 2.47.0

Additional Context

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

Yes, after updating wsl to latest, it works now.

This is likely https://github.com/microsoft/WSL/issues/9947, installing the latest wsl via github releases may solve the issue. wsl --update --pre-release from Powershell should get the latest version where 1.2.1 contains a fix.

Same - just updated to 1.2.5 https://github.com/microsoft/WSL/releases/tag/1.2.5

and can confirm this bug is fixed it must have been that wsl2 bug

Should I close this issue?

Thanks!

I forgot to mention that I also cannot sign in with --use-device-code Auth succeeds in the browser but the az CLI never finds out about it

$ az login --use-device-code
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code REDACTED to authenticate.
$ az account show
Please run 'az login' to setup account.