简体   繁体   中英

Why is VSCode "Unable to open Extension. An unknown error occurred."?

This is my first time installing and using VSCode, and when I tried installing Prettier extension, it let me peek quickly at the extension page before closing it and displaying this notification (Screenshot attached):

Unable to open 'Extension: Prettier - Code formatter': An unknown error occurred. Please consult the log for more details..

VSCode screenshot: Notification at bottom right

It's doing this with all other extensions. Searched for a solution but found nothing applicable. Why is this happening and how to fix it?

It happens that, this is a problem with the Egyptian ISPs' default DNS servers, which are most probably blocking some of Microsoft servers.

The solution (in case you live in Egypt):

  1. clear DNS cache using ipconfig /flushdns command on Windows cmd (For Other OS ).
  2. change the default DNS servers in your router settings to Google's 8.8.8.8 & 8.8.4.4 (or Cloudflare's 1.1.1.1 or any other DNS server you trust).
  3. restart VSCode and try installing extensions.

Hopefully, everything will work fine by now.

Check this Github issue for more insight.

in ubuntu go to settings -> wifi -> click on gear icon -> IP4 -> dns input and put

8.8.8.8,8.8.4.4

and click apply, to DNS Resolver Cache open terminal and type:-

sudo systemd-resolve --flush-caches
sudo systemctl restart systemd-resolved

restart your device

It probably is because of the certificate check .

Below solution works for me in CentOS 7 (Linux).

Step 1. Change the file /usr/share/applications/code.desktop

Open the file /usr/share/applications/code.desktop , then modify the Exec value with adding --ignore-certificate-errors before %F :

Exec=/usr/share/code/code --unity-launch --ignore-certificate-errors %F

Save the file with typing sudo in the begining.

文件 code.desktop

Step 2. Close all windows of vs code instances.

Step 3. Back to the terminal, use below command to open VS code:

code --ignore-certificate-errors

Step 4. Click extension button in the left side bar.

Click any extension like "Ruby" by Peng Lv, if the images in the Details page can be seen successfully, perhaps the issue is solved.

Step 5. Try to continue to install the extensions you need.

Just enjoy. May it be helpful for you.

The solution

  1. clear DNS cache using command on Windows cmd: ipconfig /flushdns

  2. change the default DNS servers in your router settings to Google's:

    8.8.8.8, 8.8.4.4 >> for IPv4

    2001:4860:4860::8888, 2001:4860:4860::8844 >> for IPv6

    This link will guide you how to change the DNS server in windows and mac: https://www.ionos.com/digitalguide/server/configuration/how-to-change-dns-server/

  3. restart VSCode and try installing extensions.

I got this "XHR failed" error in Visual Studio Code.

So I changed my network settings to use Google Public DNS ( instructions )

Finally following instructions (by mohamed-mokhtar) solved for me:

  • Go to: Control Panel\Network and Internet\Network Connections
  • Choose your connection network and ( right click on it then choose properties )
  • Select " Internet Protocol Version 4 (TCP/IPv4) and then click on properties in the bottom of this section
  • At General section click on " Use the following DNS Server address: "
  • Make " Preferred DNS server: 8.8.8.8 " (if you face a problem check this )
  • Make " Alternate DNS server: 8.8.4.4 "
  • Restart VS code

referring to @Seif A. answer

The solution (in case you live in Egypt )

clear DNS cache using command on Windows cmd:

ipconfig /flushdns

change the default DNS servers in your router settings to Google's:

8.8.8.8 , 8.8.4.4  >> for IPv4
2001:4860:4860::8888 , 2001:4860:4860::8844  >> for IPv6

restart VSCode and try installing extensions.

If you're in a corporate network and it's locked down the one last resort is to manually download the VSIX from the website on a domain that will allow it and then copy over the VSIX and install it.

I faced the same problem while adding new extension in vs code. I Recognized the problem within the ISP in Egypt, so I changed the DNS in My router to Google DNS Providers, and it works perfectly

Just install a VPN like betternet or any other VPN software and change the country to the USA or try other countries.

For windows

    cd "C:\Users\<user>\Appdata\Local\Programs\Microsoft VS Code"
    code.exe --ignore-certificate-errors

In my case I was need to disable work VPN to download extension

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM