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: enter image description here

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:

  1. Flushing my DNS cache and setting it to google's DNS server.
  2. Disabling the VPN on my laptop and restarting VS Code.
  3. Clearing the Extension search results.
  4. Disabling all the extensions currently running.

I'm using a laptop running Windows 10. Any other possible solutions I haven't tried?


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


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. ^^