How To Fix Error while fetching extensions XHR failed in Visual Studio Code

Visual Studio Code is a popular open source code editor developed by Microsoft. It has a rich ecosystem of extensions that allow you to add extra functionality and customize the editor. However, you may sometimes encounter the error “Error while fetching extensions XHR failed” when trying to install or update extensions in VS Code.

Recent Released: Is HDToday.cc a Safe and Legal Option for Streaming Movies and TV Shows? An In-Depth Review

This error indicates that VS Code was unable to connect to the extensions marketplace to download the extension for some reason. The issue is often caused by network problems, but can also occur due to other factors.

In this article, we will go through the various solutions to fix the “XHR failed” error when installing/updating extensions in Visual Studio Code.

Error While Fetching Extensions XHR Failed

1. Check Your Internet Connection

The most common reason for the error while fetching extensions xhr failed is an unstable or interrupted internet connection. VS Code requires an active internet connection to be able to connect to the extensions marketplace and download extensions.

So the first thing you should try is checking that your internet is working fine. Try opening a few websites in your browser to confirm that you can access the internet without any issues.

If you are on a corporate or university network, there may be firewalls or proxy settings that are blocking connections to the VS Code marketplace. Try switching to another network and see if the extensions can be downloaded.

Restarts your modem/router if the internet is still not working properly on your machine. This will refresh the network connection and resolve any temporary glitches.

2. Switch to Google Public DNS

In some cases, switching to Google’s Public DNS servers can resolve network-related errors. The public DNS may be faster or more reliable than the DNS your internet provider assigns.

To change to Google Public DNS:

  1. Open your network settings in Windows (Settings > Network & Internet > Change adapter options).
  2. Right click on your active network adapter and select Properties.
  3. In the properties window, scroll down and select “Internet Protocol Version 4 (TCP/IPv4)”. Click Properties.
  4. Select “Use the following DNS server addresses” and enter 8.8.8.8 as the Preferred DNS server and 8.8.4.4 as the Alternate DNS server.
  5. Click OK to save the changes.

Now try installing the extensions again in VS Code and see if the XHR error has been resolved.

3. Clear Extension Search Cache

If you get the error when searching for extensions in VS Code, it may be due to outdated search results being cached. Clearing this cache forces a fresh search, which should fix the issue.

To clear cached extension search results:

  1. In VS Code, press Ctrl+Shift+P (Cmd+Shift+P on macOS) to open the Command Palette.
  2. Type “clear extensions search results” and select the command.
  3. Restart VS Code.

Now search for extensions again and see if the XHR error appears.

4. Disable VPN and Restart VS Code

Virtual Private Networks (VPNs) can sometimes interfere with connections to the VS Code marketplace. If you are using a VPN, try disabling it completely and restarting VS Code.

Without the VPN active, VS Code should be able to access the extensions marketplace normally and install extensions without the XHR failure.

You can enable your VPN again after installing the necessary extensions.

5. Manually Download and Install Extensions

If you continually get the XHR failed error when trying to install extensions, you can try downloading extensions manually and installing them in VS Code:

  1. Go to the extension’s page on the VS Code marketplace site.
  2. Click on the Download button on the extension’s page to download a VSIX file for the extension.
  3. Once downloaded, open the VSIX file. This will install the extension directly in VS Code.

Manually installing extensions avoids the marketplace download process which seems to be failing. Just make sure to get extensions only from trusted sources like the official VS Code marketplace.

error while fetching extensions xhr failed
error while fetching extensions xhr failed

6. Check Proxy Settings

If you access the internet via a proxy server, misconfigured proxy settings in VS Code could prevent extension installations.

Try updating your proxy configuration based on your network proxy server settings.

Here’s how:

  1. Go to File > Preferences > Settings in VS Code.
  2. Search for “http proxy” and click on the Edit in settings.json option.
  3. In settings.json, add the proxy URL under the http.proxy key.

For example:

<!—->

Copy code

“http.proxy”: “http://192.168.0.1:8080”

  • Save settings.json and restart VS Code.

Install extensions again to see if proxy settings were causing the XHR error.

7. Restart VS Code with –ignore-certificate-errors

As a last resort, you can try restarting Visual Studio Code with the –ignore-certificate-errors command line flag.

This forces VS Code to ignore any SSL/TLS certificate errors when trying to connect to the extensions marketplace. The command may resolve certificate issues that cause the XHR error.

To restart VS Code with –ignore-certificate-errors:

  1. Close any currently running VS Code windows.
  2. Open a terminal (Command Prompt, Powershell, bash, etc).

Enter the following command:

<!—->

Copy code

code –ignore-certificate-errors

3. The above command will restart Code and install any extensions without certificate checks.

The XHR failed error should no longer occur when installing extensions after following this step.

Conclusion

The “Error while fetching extensions XHR failed” message can be frustrating but is usually resolvable. Most commonly, the issue is due to network problems preventing VS Code from accessing the extensions marketplace.

Try the solutions outlined above like checking internet connectivity, changing DNS servers, clearing cached results, manually downloading extensions, and modifying proxy or certificate settings. With the correct fix, you should be able to install and update VS Code extensions seamlessly.

Frequently Asked Questions

Here are some common questions about the XHR failed error in Visual Studio Code:

Q: Do I need an internet connection for VS Code extensions?

A: Yes, an active internet connection is required to be able to download and install extensions from the Visual Studio Code Marketplace. The XHR error occurs when unable to access the marketplace.

Q: Does XHR failed affect all extensions?

A: The XHR error can happen when trying to install any VS Code extension, including both Microsoft and third-party extensions. It indicates a problem connecting to the extensions marketplace.

Q: Can I access extensions without internet?

A: You can manually download VSIX files for extensions and install them offline without an internet connection. However, this will prevent updating extensions or installing new ones.

Q: Does XHR failed error appear when updating extensions?

A: Yes, the XHR failure error can appear when trying to update existing extensions as well. It affects both installing new extensions and updating previously installed ones.

Q: I keep getting XHR failed error. What should I do?

A: If you still see the error after trying the solutions in this article, some other factors could be causing the issue. Try restarting your machine, reinstalling VS Code, or installing the Insiders version to see if it resolves the problem.

Leave a Comment