'Visual Studio Code "Error while fetching extensions. XHR failed"
This problem started a few weeks ago, when I started using NordVPN on my laptop. When I try to search for an extension and even when trying to download through the marketplace I get this error:
EDIT: Just noticed another thing that might indicate to what's causing the issue. When I open VSCode and go to developer tools I get this error messege (before even doing anything):
"(node:19368) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.(Use Code --trace-deprecation ...
to show where the warning was created)"
The only partial solution I found so far was to manually download and install extensions.
I've checked similar question here and in other places online, but I didn't find a way to fix this. So far I've tried:
- Flushing my DNS cache and setting it to google's DNS server.
- Disabling the VPN on my laptop and restarting VS Code.
- Clearing the Extension search results.
- Disabling all the extensions currently running.
I'm using a laptop running Windows 10. Any other possible solutions I haven't tried?
Solution 1:[1]
In my case, the solution was to remove HTTPS_PROXY
(Could be HTTP_PROXY
) environment variable set at terminal initialization.
I removed the line which sets the environment variable for proxy, restarted the OS and the error disappeared.
Apart from ~/.bashrc
for bash or any other sh-compatible shell, environment variable could be in
/etc/environment
: specifically meant for environment variables/etc/env.d/*
: environment variables, split in multiple files/etc/profile
: all types of initialization scripts/etc/profile.d/*
: initialization scripts/etc/bashrc
,/etc/bash.bashrc
: meant for functions and aliases~/.bash_profile
: initialization for login (bash-)shells~/.bashrc
: initialization for all interactive (bash-)shells~/.profile
: used for all shells~/.cshrc
,~/.zshrc
,~/.tcshrc
: similar for non-bash shells
Credit to this post. https://unix.stackexchange.com/a/249922
Solution 2:[2]
For me , 'XHR failed' error appears when the proxy settings between your PC system and vs code are conflict.
1.Check PC system proxy settings.
2.Open cmd or terminal, type
echo %http_proxy%
, if any output, make sure it fits your pc proxy setting. Because if the proxy on vs code not being set, will be inherited from the http_proxy
and https_proxy
environment variables.
3.If none, open vs code settings.json , add
"http.proxy":"http://proxyname:port"
that fits your pc proxy setting ,without a trailing slash.
Try download extensions again.Hope this helps. ^^
Solution 3:[3]
so i find this
- press f1
- search user setting
- click enter
- search on user setting " proxy "
- click enter
- look for "use the proxy support for extensions."
- change overide to on
maybe this can help you.
Solution 4:[4]
I had the same problem, and finally, today, I just resolved it.
All you need to do is enter to the json settings file from VSC
1. Press F1
2. Type User Settings
3. Search for Proxy
4. In proxy section, look for the title `Http: Proxy Autorization`
5. Click on 'Edit in settings.json'
6. Delete all brackets containing proxy data
7. Save json file
After that, just restart VSC
You can also find the json find on %appdata%/Code/User/settings.json
Solution 5:[5]
December 10,2021.
I'm using vscode with ubuntu 20.04.
I came across the XHR errors from yesterday and could not install any extensions.
Googled a lot but nothing works.
Eventually I downloaded and installed the newest version of VSCode(deb version) and everything is fine now.
(I don't know why but maybe you can give it a try! Good Luck!)
Solution 6:[6]
I got the same error with the .deb version from the visualstudio.com page.
Have you tried opening the Developer Tools (F1, Developer Tools). Which error is returned? I had ERR_CERT_AUTHORITY_INVALID. The --ignore-certificate-errors command-line flag is a workaround for me (as indicated here https://code.visualstudio.com/docs/setup/network).
Solution 7:[7]
I have had the same issue on Debian 10 and fixed it by downgrading VSCode to an older version 1.33.1.
Solution 8:[8]
I'm using windows 11 and I was having the same issue. My laptop has a Killer wifi board and it comes with a option to "enable game fast". It was checked to start automatically with a game. I just unchecked it and this error stopped to show up.
I hope your problem will be easy as mine to solve. Try maybe your firewall.
Solution 9:[9]
As far as I am aware the XHR error has several possible causes. The easiest fix which should be attempted prior to more complicated methods is restarting VS Code.
I have seen this error a couple of times and have been able to resolve it this way, for me it was not related to proxy settings, whereas for other users it might be. A possible relevant scenario is running a VS Code instance without restart or update over prolongued periods of time, such as days or even weeks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow