RONOLULU
RONOLULU

Reputation: 1087

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?

Upvotes: 94

Views: 458658

Answers (30)

Jordy
Jordy

Reputation: 1960

In my case, just only sign in with Microsoft Account works for me according to Drew Kimani comment on this question. Please follow this steps:

  1. Open VS Code, click profile logo then click Turn On Cloud Changes step 1

  2. Choose Sign In with Microsoft and follow the next steps. step 2

After done, it will resolve this problem.

Upvotes: 3

Craig McQueen
Craig McQueen

Reputation: 43426

It's worth checking if Microsoft's service is online:

https://marketplace.visualstudio.com/

As I write this, it says "Azure DevOps Services Unavailable".

Sorry! Our services aren't available right now.

We're working to restore all services as quickly as possible. Please check back soon.

Upvotes: 2

Sql Surfer
Sql Surfer

Reputation: 1422

2024 Settings Specifics for XHR Error in VS Code

The following is relavent - but it is not a root cause. These settings may allow you to install one extension at a time but you have to restart VS Code to install each extension.

1 - Look at Your Settings

Settings Gear (or Search User Settings)

2 - Choose Settings From the Flyout

Settings Flyout Menu

3 - Look at your Application - Proxy settings

enter image description here

The User Settings for your Application - Proxy within VS Code probably should be something different. Notice if your settings are "synced" acrosss devices -this may be relavent to your situation.

Upvotes: 1

Binjie Liang
Binjie Liang

Reputation: 932

I had the same problem, I did the following steps to solve 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 Authorization
  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 in %appdata%/Code/User/settings.json

Upvotes: 81

David Mzareulyan
David Mzareulyan

Reputation: 41

I had the same problem. I had no proxy on the system and no proxy entries in the settings. VS Code could not access the network.

The solution for me was to reinstall VS Code using the "System Installer" instead of the "User Installer", thanks to the hint on this thread: https://github.com/Microsoft/vscode/issues/56657:

Can you uninstall the User Setup and install the System Setup and see whether that fixes it?

yes, i uninstall the user setup and try the system setup, and it works .

Upvotes: 0

Eray Erdin
Eray Erdin

Reputation: 3149

For me,it suddenly started working after 4 hours. I don't know if the problem was from my ISP or VSCode Extension server, but it somehow solved itself.

Upvotes: 0

talent makhanya
talent makhanya

Reputation: 29

You can also check if http_proxy is set as an environment variable and delete that line if set and no longer on a network that has proxy set-up.

enter image description here

Upvotes: 0

Pranjal Kumar
Pranjal Kumar

Reputation: 175

For me the problem was just that my proxy server was on, in my Windows machine. I was earlier working with network tracing, and it seemed to be causing the error.

Problem message:

Problem message

Solution: resetting proxy settings

Proxy server settings in windows 11

So I just turned off everything in proxy settings or you can reset it to default.

Upvotes: 0

snowpeak
snowpeak

Reputation: 867

In my case, the solution was to remove HTTPS_PROXY (Could be HTTP_PROXY) environment variable set during terminal initialisations.

Environment variables can be confirmed by env command for most operating systems.

I removed the line which sets the environment variable for proxy from the bash profile, then restarted the OS.

Apart from ~/.bashrc for bash or any other sh-compatible shell, the 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

The environment variable HTTP(S)_PROXY may be used by other applications. Therefore, be aware of the side effects of removing it.

Upvotes: 8

IKriKan
IKriKan

Reputation: 1147

Following worked for me :

  • press f1
  • search user setting
  • click enter search on user setting " proxy "
  • click enter
  • remove the value present in "Http: Proxy"

Upvotes: 3

Alex Seceleanu
Alex Seceleanu

Reputation: 535

Same problem, updated VS Code on mac while connected to the VPN. After the update I got the XHR Error.

The solution was to stop the VPN, connect to the host and then reconnect the VPN and it seems to work normally. For now.

Upvotes: -1

david.pfx
david.pfx

Reputation: 10868

Same problem, easy solution: just login to Microsoft account and sync settings.

At least try this before all the other more complicated things?

Upvotes: 0

Jan Frederik
Jan Frederik

Reputation: 712

I faced the same problem, however no proxy or VPN. Solved it by entirely erasing my vscode config folders: %appdata%\Code and %userprofile%\.vscode. (As explained in https://stackoverflow.com/a/75473624/2381133.)

Upvotes: 1

Rahul Bhat
Rahul Bhat

Reputation: 113

This is an issue with the proxy setting.

  • Press F1
  • Type User Settings
  • Search for "Proxy"
  • Http:Proxy will be empty
  • Add your proxy here with http://username:password@SERVER:PORT

And just restart visual studio code

Upvotes: 7

SpiRail
SpiRail

Reputation: 1415

I just restarted my entire computer and it worked.

I hate to have this dumb answer. But, I did look into most of the other answers. When something smells like a network issue and you "didn't change anything", it can be many things.

Upvotes: 0

Yerbol
Yerbol

Reputation: 405

I had same error: while fetching extensions xhr failed visual studio code on Mac and Windows.

VPN solved my problems.

Upvotes: -1

numan
numan

Reputation: 85

I had this problem in linux,

Manually downloading did not work with an error like: "Request was blocked due to exceeding usage of resource 'Count' in namespace AnnonymousID ..." (I did not save the full message unfortunately). I think Network speed was not an issue because my collage who was connected to same network was able to download extensions.

closing all instances of vscode and re-opening solved it.

Upvotes: 0

jatharthan
jatharthan

Reputation: 31

If you are using windows 11 with @binjie-liang answer, in your windows search for proxy settings and toggle off the Automatically Detect Settings. This will resolve the issue. Should be same with windows 10 also

Upvotes: 1

Brixomatic
Brixomatic

Reputation: 417

Using the task manager I noticed that I had another vscode-instance running that was not closed properly. Shutting every vscode instance down using the Task manager, restarting it I got two vscode-windows, closed one, could install in the remaining one.

Upvotes: 1

Lotfi
Lotfi

Reputation: 320

I had the same issue .. it's a very specific solution that worked for me but I hope it helps someone who will pass by here in the future:

Apparently .. I disconnected Cloudflare Zero Trust "Warp 1.1.1.1" in the CLI by mistake and some applications (vscode,firefox,skype ..) were using it .. so all I had to do was reconnect .. if your warp tray icon doesn't work like mine then all you have to do is type the command:

warp-cli connect

And all was back to working.

Upvotes: 1

Akash Darji
Akash Darji

Reputation: 415

Simply follow below steps:

  1. Press F1
  2. Type User Settings
  3. Search for "Proxy Authorization"
  4. Click on "Edit in settings.json"
  5. Add new key value pair - "http.proxySupport": "on"
  6. Save JSON file

At my end settings.json file

{
    "http.proxyAuthorization": null,
    "http.proxySupport": "on"
}

Upvotes: 25

Sami Tarazi
Sami Tarazi

Reputation: 71

Running Windows 11, it is Windows Firewall preventing it.

  1. Open Windows Security
  2. Click on Firewall & Network Security
  3. Click on Allow an app through the firewall
  4. Click on Change Settings
  5. Click on Allow Another App
  6. Browse to where VS Code is installed and click on Code.exe
  7. Make sure that Code shows in the list of the allowable apps

And that is it

Hope it works with you as well.

S.

Upvotes: 2

cyicz123
cyicz123

Reputation: 45

I have faced the same issue. And I delete the .vscode-server directory in server. Reconnect my server successful.

Upvotes: 1

Melon
Melon

Reputation: 497

so i find this

  1. press f1
  2. search user setting
  3. click enter
  4. search on user setting " proxy "
  5. click enter
  6. look for "use the proxy support for extensions."
  7. change override to on

maybe this can help you.

Upvotes: 48

iAviator
iAviator

Reputation: 1447

In my case http_proxy system environment variable was set in Windows 10. After deleting that VS code started loading extensions.

Upvotes: 3

Sukh
Sukh

Reputation: 540

For me i had to disable this option from Visual Studio Code.

For me i had to disable this option from Visual Studio Code.

Upvotes: 2

Lewy Blue
Lewy Blue

Reputation: 618

I don't use a proxy, and I do use NextDNS so I didn't want to change my DNS settings.

As a workaround, you can open code with --ignore-certificate-errors flag, install any extensions, then restart without the flag.

On windows:

code --ignore-certificate-errors

Upvotes: 23

Manoj Reddy
Manoj Reddy

Reputation: 127

In my Windows machine deleting http_proxy User Environment Variable helped me.

Upvotes: 0

Bashar Issa
Bashar Issa

Reputation: 153

I faced this problem in 7-2022, and it's gone without even restart vscode. The reason was poor internet connection. If this is ur situation check the quality of your internet connection and just click refresh button, then extensions appear after a moment!

Upvotes: -1

Koenigsberg
Koenigsberg

Reputation: 1798

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.

Upvotes: 2

Related Questions