Do you want to fix XHR Failed error in VSCode?
At its heart, VSCode is based on the Electron framework. That means VSCode is basically a Chromium with code editing features developed on top of it. Whenever you get an error from VSCode, it's most likely Chromium errors.
Users have reported that when they try to install an extension, especially behind a proxy network, they are presented with XHR Failed error. XHR Failed indicates that a few XHR requests may have been failed or interrupted while VSCode sends and receives extension information from the server.
In this article, we will discuss about possible fix for XHR Failed error in VSCode.
Use a direct internet connection
If you're behind a proxy network, try to disable it if you can.
Most of the time, the proxy network includes a firewall that may block VSCode requests to its servers.
In rare cases, the proxy network supports only HTTP or HTTPS protocol, leaving other communication through its network blocked, which can causes strange behavior in VSCode.
You can follow the instructions from Microsoft Forum to disable proxy on Windows 10. macOS users can consult this guide to do just that. Linux users should be able to disable proxy on their own, given that they are often more tech-savvy, but here's a few tips on how to turn off proxy in Linux anyway.
Turn on automatic proxy detection
Chromium uses system proxy settings by default, so there's a chance VSCode's Chromium core does not recognize the proxy and cannot send/receive network data.
In order to turn on automatic proxy detection on Windows 10, follow HowToGeek guide.
Ignore certificate errors in VSCode
The actual implementation of the corporate proxy can vary from organization to organization, but there is one thing in common : they could all cause certificate errors.
Secure websites and applications use their own certificate to prevent themselves from online attacks. Internet traffic going through a corporate proxy can be modified by the proxy network in real time, causing certificate irregularities. Some other times, your organization offers their own CA certificate, which makes the situation even more complex.
You can try launching VSCode with
--ignore-certificate-errors flag to disable strict certificate checking.
On Windows, the easiest way to do this is by running
code.exe --ignore-certificate-errors from a Command Prompt window.
On Linux and macOS, you have to open Terminal app and run
After that, try installing the extensions again to see whether the error message goes away.
Disable JS source maps
On Developer Tools that just pops up, click the Gear button (settings button) in the upper right corner.
Change your DNS
If you live in a country where heavy internet censorship is implemented, such as China, Egypt or Turkey, maybe the firewall has blocked some Microsoft servers. You can try setting your DNS to Google DNS (220.127.116.11) or Cloudflare's 18.104.22.168 servers to see if XHR Failed happens again or not. On Windows, you may have to run
ipconfig /flushdns to flush the system's DNS cache before changing the DNS.
On Linux machines, you have to edit
/etc/resolvconf/resolv.conf.d/base to make DNS changes persistent through restarts. Add these two lines to the file before rebooting so that the changes take effect.
nameserver 22.214.171.124 nameserver 126.96.36.199
Install the extension offline using VSIX file
All VSCode extensions is now available in the form of VSIX-packaged files. This allows for offline installation as well as extensions which are not originated from VSCode Marketplace.
You can download VSIX files directly from VSCode Marketplace or Open VSX Registry and install it offline, without the need for an internet connection. See our guide on How to install extensions in VSCode for detailed installation steps.
We hope that this article helps you solve the XHR Failed error in VSCode. VSCode is an awesome code editor, equipped with numerous features that supports developers. Here's a few of them that we've covered, if you're interested :