When you try to install a VS Code extension and see the error message "Unable to install extension 'extension-name'. Please try again later" or "Failed to install extension: network error," the problem usually stems from marketplace connectivity, permission issues, or corrupted cache files. Here's how to diagnose and fix each scenario.

Diagnosing the Problem

First, determine which type of installation failure you're experiencing. Open the Output panel by pressing Ctrl+Shift+U (Windows/Linux) or Cmd+Shift+U (Mac) and select "Extensions" from the dropdown menu. Look for specific error patterns:

Network-related errors: - getaddrinfo ENOTFOUND marketplace.visualstudio.com - fetch failed - ETIMEDOUT

Permission-related errors: - EACCES: permission denied - EPERM: operation not permitted

Corruption-related errors: - Extension is invalid - Corrupt zip file - Signature verification failed

Solution 1: Check Network and Marketplace Connectivity

If you see network-related errors, VS Code cannot reach the Microsoft Extension Marketplace.

Step 1: Verify your internet connection works for other applications.

Step 2: Check if the marketplace is accessible. Open a browser and navigate to https://marketplace.visualstudio.com/vscode. If the site doesn't load, there may be a temporary outage.

Step 3: If you're behind a corporate firewall or proxy, configure VS Code to use it. Open Settings (Ctrl+,) and search for "proxy". Set http.proxy to your proxy URL:

json
"http.proxy": "http://proxy.company.com:8080"

Also enable http.proxyStrictSSL if your proxy uses a self-signed certificate:

json
"http.proxyStrictSSL": false

Step 4: Restart VS Code after changing proxy settings.

Solution 2: Fix Permission Issues

Permission errors occur when VS Code cannot write to the extensions directory.

Step 1: Find your extensions directory. By default, it's located at: - Windows: %USERPROFILE%\.vscode\extensions - macOS: ~/.vscode/extensions - Linux: ~/.vscode/extensions

Step 2: Check the permissions. On Windows, right-click the .vscode folder, select Properties > Security, and ensure your user has Full Control. On macOS/Linux, run:

bash
ls -la ~/.vscode

You should see your username as the owner. If not, fix ownership:

bash
sudo chown -R $(whoami) ~/.vscode

Step 3: If you previously ran VS Code as administrator (Windows) or with sudo (macOS/Linux), extension folders may have incorrect ownership. Reset the entire extensions directory:

```bash # macOS/Linux sudo chown -R $(whoami) ~/.vscode/extensions

# Windows (run in PowerShell as regular user) icacls "%USERPROFILE%\.vscode" /grant %USERNAME%:F /t ```

Solution 3: Clear Corrupted Extension Cache

When extensions fail mid-installation, corrupted cache files can block future attempts.

Step 1: Close all VS Code windows completely.

Step 2: Delete or rename the cached extension files:

  • Windows: Delete %USERPROFILE%\.vscode\extensions\.obsolete and any .pending folders
  • macOS/Linux: Delete ~/.vscode/extensions/.obsolete and .pending-* folders

Step 3: Clear VS Code's cache directory:

  • Windows: Delete %APPDATA%\Code\Cache, %APPDATA%\Code\CachedData, and %APPDATA%\Code\CachedExtensionVSIXs
  • macOS: Delete ~/Library/Application Support/Code/CachedExtensionVSIXs
  • Linux: Delete ~/.config/Code/CachedExtensionVSIXs

Step 4: Restart VS Code and try installing the extension again.

Solution 4: Install Extension Manually

If the marketplace installation continues to fail, download and install the extension manually.

Step 1: Go to https://marketplace.visualstudio.com/items?itemName=publisher.extension-name (replace with the actual publisher and extension name).

Step 2: Click "Download" to get the .vsix file.

Step 3: In VS Code, open the Command Palette with Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac).

Step 4: Type "Install from VSIX" and select "Extensions: Install from VSIX..."

Step 5: Navigate to and select the downloaded .vsix file.

Solution 5: Reset VS Code to Defaults

If nothing else works, a clean reinstall may be necessary.

Step 1: Uninstall VS Code.

Step 2: Remove all VS Code data directories:

  • Windows: Delete %APPDATA%\Code, %USERPROFILE%\.vscode
  • macOS: Delete ~/Library/Application Support/Code, ~/.vscode
  • Linux: Delete ~/.config/Code, ~/.vscode

Step 3: Download and install a fresh copy of VS Code.

Step 4: Install extensions one at a time to identify any problematic extension.

After following these steps, your extension installation should work properly. If problems persist with a specific extension, check that extension's GitHub issues page for known compatibility problems with your VS Code version.