VisualStudio
VisualStudio copied to clipboard
Unable to connect to GitHub from VS2019
Hello, I'm having troubles to connect to GitHub from Visual Studio 2019,
Versions
- GitHub Extension for Visual Studio version: v2.11.106.19330
- Visual Studio version: 2019 (16.7.30503.244)
What happened
The extension login view opens the browser at https://github.com/login/oauth/authorize?client_id=**********
and keeps loading without any response. Google chrome status bar shows the message : Waiting for localhost...
Screenshots
Logs
Additional context
I tried to uninstall the extension and install it again, revert to previous version, cleaning extension app data folder, cleaning VS 2019 cache but without success.
Hi @cyounes,
The extension uses a server running localhost
to receive a callback from the web-flow login. Might you have some security/firewall software installed that is blocking connections to localhost
?
I'm keen to discover what the problem is here. Please let me know if you have any ideas!
@jcansdale So finally I got it working based on your comment 😄
In fact, I did 4 steps, I don't know which one worked I suppose the last one
- I cleaned the .git-credentials, it was containing hundreds of lines with the same token. (Because I was always been asked for the username and password for each Git operation).
- I set my Wireless network as private (it was set by default as Public).
- I run Visual Studio as Administrator (VS 2019 professional )
- I disconnected from VPN !
I suppose the last step was the step that solved the problem... hopefully this will help others facing the same issue.
Hi @cyounes,
I disconnected from VPN ! I suppose the last step was the step that solved the problem... hopefully this will help others facing the same issue.
Thanks for letting me know how you got on here. I had no idea that VPNs might redirect localhost
to a different server! It should be possible to use 127.0.0.1
instead of localhost
. Would you be up for having another try once I've changed this to confirm whether or not it works?
@jcansdale No problem, Just le me know when I have to test it. By the way, the VPN is even preventing to resolve some local IP addresses in a private network like ex 192.168.1.1. Then I'm not sure switching localhost to 127.0.0.1 will solve the problem.
@cyounes could you try doing ping localhost
when connected to your VPN? I'm interested to find out if it's pointing at 127.0.0.1
!
By the way, the VPN is even preventing to resolve some local IP addresses in a private network like ex 192.168.1.1. Then I'm not sure switching localhost to 127.0.0.1 will solve the problem.
Good question. I guess it depends whether it's a DNS issue when connected to the VPN. 🤔
@jcansdale Seems there is no problem with ping when connecting to VPN
>ping localhost
Pinging ******* [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Ping statistics for ::1:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
Control-C
^C
>ping 127.0.0.1
Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Ping statistics for 127.0.0.1:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
Control-C
^C
Reply from ::1: time<1ms
Oh, is this an IPv6 address? I wonder if that might be the issue? 🤔
@jcansdale Well today got the same problem, I wasn't connected to VPN, but suddenly Github extension got disconnected and requested me to reconnect again. I finally had to apply the 3rd step from the steps I mentioned above:
- [x] Right click on VS2019 in start menu, and run as administrator.
Without admin rights it's not possible to connect to Github as the login as the browser hangs on Waiting for localhost
. (At least in my case 🐞 )
Thanks for your help. 🤝
@cyounes,
Right click on VS2019 in start menu, and run as administrator.
Interesting, I wonder what difference that would make?
I see we're listening on localhost
not 127.0.0.1
. I wonder if that makes a difference? 🤔
https://github.com/github/VisualStudio/blob/74303c601c7d3f56d86c2cbffb2ee289588c8a73/src/GitHub.App/Services/OAuthCallbackListener.cs#L43
Hi again @jcansdale !
I come back to you because I have enabled verbose logging before I get again the same error. In fact, VS2019 is configured to run as administrator, I mean each time I double click on VS2019 is running with admin privileges, (At least this is what I see in the top right corner of VS). => Screenshots below. 👇
1. Time [23:51:08]
Today I double clicked and got the following message in "Connections" of Team Explorer :
2. Time [23:56:29]
I tried to fetch changes from GitHub the got asked to enter my GitHub credentials:
3. Time [00:01:47] 💚
I closed VS2019 without entering my credentials as was asked in previous step and went to start menu, clicked right on VS shortcut, Run as Administrator, the result is GitHub connected successfully!
I don't know if there is a difference between configuring an app to run as Admin by default and Right Click then run as admin. But what I'm sure about, is that GitHub extension is failing to see GitHub during a moment of time because some reason... In other words, I don't see why Admin privileges could make difference ❓ ❗
🔴 The only clear error in logs:
2020-10-22 23:56:29.247 [13436] EROR [11] GitHubServiceProvider Error loading GitHub.Services.IConnectionManager System.InvalidOperationException: Due to high risk of deadlock you cannot call GetService from a background thread in an AsyncPackage derived class. You should instead call GetServiceAsync (without calling Result or Wait on the resultant Task object) or switch to the UI thread with the JoinableTaskFactory.SwitchToMainThreadAsync method before calling GetService. at Microsoft.VisualStudio.Shell.AsyncPackage.GetService(Type serviceType) at Microsoft.VisualStudio.Shell.Package.System.IServiceProvider.GetService(Type serviceType) at GitHub.VisualStudio.GitHubServiceProvider.TryGetService(Type serviceType)
Full Logs from the actions mentioned above
Here is the logs from VS extension.log (Edited for privacy 😄 )
2020-10-22 23:51:08.116 [04772] INFO [81] GitHubPackage Initializing GitHub Extension v2.11.106.19330 in Microsoft Visual Studio 2019 (16.7.30611.23) 2020-10-22 23:51:08.132 [04772] INFO [23] LogManager Set Logging Level: "Verbose" 2020-10-22 23:51:08.190 [04772] DBUG [69] TeamExplorerContext ActiveRepository changed to https://github.com/***************** @ C:\Users\******************** 2020-10-22 23:51:36.580 [04772] DBUG [43] VSGitExt IGitExt.ActiveRepositories (#42991062) returned ["C:\\Users\\***********************"] 2020-10-22 23:51:36.595 [04772] DBUG [43] VSGitExt ActiveRepositories changed to ["https://github.com/*****************************"] 2020-10-22 23:53:30.173 [13436] INFO [86] GitHubPackage Initializing GitHub Extension v2.11.106.19330 in Microsoft Visual Studio 2019 (16.7.30611.23) 2020-10-22 23:53:30.191 [13436] INFO [10] LogManager Set Logging Level: "Verbose" 2020-10-22 23:54:56.075 [13436] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories busy:true 2020-10-22 23:54:56.085 [13436] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories busy:true 2020-10-22 23:54:56.440 [13436] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories busy:true 2020-10-22 23:54:56.440 [13436] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories busy:true 2020-10-22 23:54:56.656 [13436] DBUG [01] GitHubConnectSection Title title:Local Git Repositories (4) busy:true 2020-10-22 23:54:56.656 [13436] DBUG [01] GitHubConnectSection Title title:Local Git Repositories (4) busy:true 2020-10-22 23:54:56.656 [13436] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories (4) busy:false 2020-10-22 23:54:56.664 [13436] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories (4) busy:false 2020-10-22 23:54:56.857 [13436] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories (4) busy:false 2020-10-22 23:54:56.857 [13436] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories (4) busy:false 2020-10-22 23:56:29.237 [13436] VERB [01] UsageTracker Creating VisualStudioUsageTracker 2020-10-22 23:56:29.239 [13436] VERB [11] UsageTracker Increment counter NumberOfStartups 2020-10-22 23:56:29.247 [13436] EROR [11] GitHubServiceProvider Error loading GitHub.Services.IConnectionManager System.InvalidOperationException: Due to high risk of deadlock you cannot call GetService from a background thread in an AsyncPackage derived class. You should instead call GetServiceAsync (without calling Result or Wait on the resultant Task object) or switch to the UI thread with the JoinableTaskFactory.SwitchToMainThreadAsync method before calling GetService. at Microsoft.VisualStudio.Shell.AsyncPackage.GetService(Type serviceType) at Microsoft.VisualStudio.Shell.Package.System.IServiceProvider.GetService(Type serviceType) at GitHub.VisualStudio.GitHubServiceProvider.TryGetService(Type serviceType) 2020-10-23 00:01:47.956 [11628] INFO [81] GitHubPackage Initializing GitHub Extension v2.11.106.19330 in Microsoft Visual Studio 2019 (16.7.30611.23) 2020-10-23 00:01:47.965 [11628] INFO [13] LogManager Set Logging Level: "Verbose" 2020-10-23 00:01:47.995 [11628] DBUG [06] TeamExplorerContext ActiveRepository changed to https://github.com/********************* @ C:\Users\**************** 2020-10-23 00:01:50.177 [11628] VERB [01] UsageTracker Creating VisualStudioUsageTracker 2020-10-23 00:01:50.177 [11628] VERB [01] UsageTracker Increment counter NumberOfLogins 2020-10-23 00:02:16.552 [11628] DBUG [40] VSGitExt IGitExt.ActiveRepositories (#40847598) returned ["C:\\Users\\*************************"] 2020-10-23 00:02:16.564 [11628] DBUG [40] VSGitExt ActiveRepositories changed to ["https://github.com/***********************"] 2020-10-23 00:02:17.513 [11628] DBUG [34] TeamExplorerContext Fire StatusChanged event if anything about an active repository has changed 2020-10-23 00:02:21.095 [11628] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories busy:true 2020-10-23 00:02:21.100 [11628] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories busy:true 2020-10-23 00:02:21.153 [11628] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories busy:true 2020-10-23 00:02:21.153 [11628] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories busy:true 2020-10-23 00:02:21.184 [11628] DBUG [01] GitHubConnectSection Title title:Local Git Repositories (4) busy:true 2020-10-23 00:02:21.184 [11628] DBUG [01] GitHubConnectSection Title title:Local Git Repositories (4) busy:true 2020-10-23 00:02:21.184 [11628] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories (4) busy:false 2020-10-23 00:02:21.185 [11628] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories (4) busy:false 2020-10-23 00:02:21.200 [11628] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories (4) busy:false 2020-10-23 00:02:21.200 [11628] DBUG [01] GitHubConnectSection IsBusy title:Local Git Repositories (4) busy:false
What worked for me was deleting all my cookies and browsing history (From Microsoft Edge Browser)
Hi @YounesCheikh,
The extension uses a server running
localhost
to receive a callback from the web-flow login. Might you have some security/firewall software installed that is blocking connections tolocalhost
?I'm keen to discover what the problem is here. Please let me know if you have any ideas!
That issue appear on my GitHub login attempts too. I solved it with turn off the Private Network Firewall + Run Visual Studio as administrator.