When VS Code can't connect to the internet to install extensions, sync settings, or access remote features, and you're behind a corporate proxy, you need to properly configure proxy settings. Common error messages include "Failed to fetch extensions," "Network error: connection refused," "Self-signed certificate in certificate chain," and "Proxy authentication required."
Understanding VS Code Network Connections
VS Code makes network connections for: - Extension marketplace - Settings sync - Remote development (SSH, Containers, WSL) - Live Share - Built-in update checks - Language server downloads
Each of these may need proxy configuration.
Solution 1: Configure HTTP Proxy Settings
VS Code has built-in proxy settings that apply to most network operations.
Step 1: Open Settings (Ctrl+, or Cmd+,).
Step 2: Search for "proxy" and find HTTP Proxy settings.
Step 3: Set the proxy URL:
"http.proxy": "http://proxy.company.com:8080"For HTTPS proxy:
"http.proxy": "https://proxy.company.com:8080"For SOCKS proxy:
"http.proxy": "socks5://proxy.company.com:1080"Step 4: Include authentication if required:
"http.proxy": "http://username:password@proxy.company.com:8080"Warning: Storing passwords in settings.json is not secure. Consider using environment variables instead (see Solution 4).
Step 5: Restart VS Code after changing proxy settings.
Solution 2: Handle SSL/TLS Certificate Issues
Corporate proxies often use self-signed certificates, causing "Self-signed certificate" or "Certificate chain" errors.
Step 1: Disable SSL verification (not recommended for production):
"http.proxyStrictSSL": falseStep 2: Better approach: Add the corporate root certificate to your system trust store.
- 1.Windows:
- 2.Get your corporate root certificate (usually from IT)
- 3.Open "Manage computer certificates" (certlm.msc)
- 4.Navigate to Trusted Root Certification Authorities > Certificates
- 5.Right-click > All Tasks > Import
- 6.Select your corporate certificate
macOS:
``bash
# Add certificate to system keychain
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /path/to/corporate-root.crt
Linux: ```bash # Ubuntu/Debian sudo cp corporate-root.crt /usr/local/share/ca-certificates/ sudo update-ca-certificates
# RHEL/CentOS/Fedora sudo cp corporate-root.crt /etc/pki/ca-trust/source/anchors/ sudo update-ca-trust ```
Step 3: Restart VS Code after adding certificates.
Solution 3: Configure Proxy Authentication
If your proxy requires authentication and basic auth in the URL doesn't work.
Step 1: Try NTLM authentication (Windows):
"http.proxySupport": "on",
"http.proxyStrictSSL": falseStep 2: For proxy that prompts for credentials, VS Code should show a dialog. If it doesn't:
```json // Enable proxy support "http.proxySupport": "on"
// Try different authentication methods "http.proxyAuthorization": "NTLM" // or "Negotiate" or "Basic" ```
Step 3: Check if your system proxy settings work:
Windows: - Settings > Network & Internet > Proxy - Configure system proxy there - VS Code will use system proxy by default
macOS: - System Preferences > Network > Advanced > Proxies - Configure system proxy settings
Linux: - Set environment variables (see Solution 4)
Step 4: Verify VS Code is using system proxy:
"http.proxySupport": "system" // Use system proxy settingsSolution 4: Use Environment Variables for Proxy
Environment variables are more secure and often work better than settings.
Step 1: Set proxy environment variables:
Windows (Command Prompt):
``cmd
set HTTP_PROXY=http://proxy.company.com:8080
set HTTPS_PROXY=http://proxy.company.com:8080
set NO_PROXY=localhost,127.0.0.1,*.company.com
Windows (PowerShell):
``powershell
$env:HTTP_PROXY = "http://proxy.company.com:8080"
$env:HTTPS_PROXY = "http://proxy.company.com:8080"
$env:NO_PROXY = "localhost,127.0.0.1,*.company.com"
macOS/Linux (Bash):
``bash
export HTTP_PROXY="http://proxy.company.com:8080"
export HTTPS_PROXY="http://proxy.company.com:8080"
export NO_PROXY="localhost,127.0.0.1,*.company.com"
macOS/Linux (Zsh):
``bash
# Add to ~/.zshrc for persistence
echo 'export HTTP_PROXY="http://proxy.company.com:8080"' >> ~/.zshrc
echo 'export HTTPS_PROXY="http://proxy.company.com:8080"' >> ~/.zshrc
Step 2: For authenticated proxy:
export HTTP_PROXY="http://username:password@proxy.company.com:8080"
export HTTPS_PROXY="http://username:password@proxy.company.com:8080"Step 3: Launch VS Code from the terminal with these environment variables:
code- 1.Step 4: On Windows, you can set environment variables permanently:
- 2.Search "Environment Variables" in Start menu
- 3.Edit system or user environment variables
- 4.Add HTTP_PROXY and HTTPS_PROXY
Solution 5: Configure Proxy for Extensions
Some extensions have their own proxy settings.
Step 1: For Python extension:
"python.proxy": "http://proxy.company.com:8080"Step 2: For npm-based extensions:
Create or edit .npmrc in your home directory:
proxy=http://proxy.company.com:8080
https-proxy=http://proxy.company.com:8080
strict-ssl=falseStep 3: For Git operations:
git config --global http.proxy http://proxy.company.com:8080
git config --global https.proxy http://proxy.company.com:8080To use credential helper with proxy:
git config --global credential.helper managerStep 4: For remote development (SSH, Containers), ensure the remote environment also has proxy access.
Solution 6: Debug Network Connections
If proxy settings don't work, enable network debugging to see what's happening.
Step 1: Enable network logging:
"http.systemCertificates": true,
"http.proxySupport": "on"Step 2: Check the output for network errors: - View > Output - Select "Log (Window)" from dropdown - Look for network-related error messages
Step 3: Test the connection:
- Command Palette > "Developer: Open Webview Developer Tools"
- Open Console tab
- Try to load a URL:
- ```javascript
- fetch('https://marketplace.visualstudio.com')
- .then(r => console.log('Success:', r.status))
- .catch(e => console.error('Failed:', e))
`
Step 4: Check if other applications work with the proxy:
- Try accessing https://marketplace.visualstudio.com in your browser
- If browser works but VS Code doesn't, the issue is VS Code-specific
Solution 7: Handle Proxy Auto-Configuration (PAC)
Some networks use PAC files for automatic proxy configuration.
Step 1: Get the PAC URL from your IT department or system settings.
Step 2: VS Code doesn't directly support PAC files, but you can:
Option A: Parse the PAC file manually and extract the proxy: - Open the PAC URL in a browser - It's a JavaScript file that returns proxy settings - Use the returned proxy in VS Code settings
Option B: Use a local proxy that supports PAC:
- 1.Install a tool like
px(Python proxy): - 2.```bash
- 3.pip install px-proxy
- 4.px --pac=http://company.com/proxy.pac
- 5.
` - 6.Configure VS Code to use the local proxy:
- 7.```json
- 8."http.proxy": "http://localhost:3128"
- 9.
`
Solution 8: Configure for Different Network Profiles
If you switch between networks (office with proxy, home without proxy):
Step 1: Use the http.proxySupport setting:
// Auto-detect when to use proxy
"http.proxySupport": "off" // Disable proxy entirely
"http.proxySupport": "on" // Always use configured proxy
"http.proxySupport": "system" // Use system proxy settingsStep 2: Create different VS Code profiles:
- 1.Command Palette > "Preferences: Open Settings (JSON)"
- 2.Create different setting files for different networks
- 3.Switch manually when changing networks
Step 3: Use a startup script:
Create a script that sets environment variables and launches VS Code:
Windows (proxy-on.bat):
``batch
set HTTP_PROXY=http://proxy.company.com:8080
set HTTPS_PROXY=http://proxy.company.com:8080
code
macOS/Linux (proxy-on.sh):
``bash
#!/bin/bash
export HTTP_PROXY="http://proxy.company.com:8080"
export HTTPS_PROXY="http://proxy.company.com:8080"
code
Solution 9: Fix Extension-Specific Proxy Issues
Some extensions have unique proxy requirements.
For Live Share:
``json
"liveshare.proxy.enabled": true,
"liveshare.proxy.address": "http://proxy.company.com:8080"
For Remote SSH: SSH uses its own connection method. Configure SSH config:
Host myserver
HostName server.company.com
User username
ProxyCommand nc -X connect -x proxy.company.com:8080 %h %pFor Windows with PuTTY:
``
Host myserver
HostName server.company.com
User username
ProxyCommand C:\Program Files\PuTTY\plink.exe -proxy proxy.company.com:8080 %h %p
For Docker/Containers:
Configure Docker daemon proxy in ~/.docker/config.json:
``json
{
"proxies": {
"default": {
"httpProxy": "http://proxy.company.com:8080",
"httpsProxy": "http://proxy.company.com:8080",
"noProxy": "localhost,127.0.0.1"
}
}
}
Solution 10: Test with a Simple Connection
Verify your proxy configuration works.
Step 1: Test from a terminal:
```bash # Set proxy export HTTP_PROXY="http://proxy.company.com:8080" export HTTPS_PROXY="http://proxy.company.com:8080"
# Test connection curl -I https://marketplace.visualstudio.com
# Should return HTTP 200 if proxy works ```
Step 2: Test extension installation:
- Open Extensions panel (Ctrl+Shift+X)
- Search for a popular extension like "Prettier"
- Try to install it
- Check for error messages
Step 3: Test settings sync: - Enable Settings Sync - Check if it connects to Microsoft servers - Look for errors in the sync status
After applying these solutions, VS Code should successfully connect through your proxy. If problems persist, contact your IT department for the correct proxy settings, PAC file URL, or certificate installation requirements.