If your network uses a proxy server to connect to the internet, GitHub Copilot in VS Code may fail to authenticate or generate suggestions. The Copilot extension cannot bypass your corporate or home proxy automatically. This article explains how to configure proxy settings for GitHub Copilot in VS Code using environment variables, the settings.json file, and proxy authentication if required.
Key Takeaways: Configuring GitHub Copilot Proxy in VS Code
- VS Code settings.json > github.copilot.advanced: Set the proxy URL directly in VS Code settings for Copilot only.
- Environment variables HTTP_PROXY and HTTPS_PROXY: Configure system-wide proxy that Copilot and other extensions respect.
- Proxy authentication with username and password: Add credentials in the proxy URL or use the keychain for secure storage.
How GitHub Copilot Connects Through a Proxy
GitHub Copilot is a cloud-based AI code completion tool. The VS Code extension sends code context to GitHub servers and receives suggestions. When your network requires a proxy, the Copilot extension must be told how to reach those servers. VS Code itself can use proxy settings from environment variables or its own configuration. However, Copilot has a dedicated setting that overrides the general VS Code proxy. If you do not configure either, Copilot will fail with connection errors such as Unable to reach Copilot service or Authentication failed. The proxy can be an HTTP, HTTPS, or SOCKS proxy. You can configure it per machine or per user.
Prerequisites
Before you configure proxy settings, confirm the following:
- You have the proxy server address and port number. Example:
http://proxy.example.com:8080 - If the proxy requires authentication, you have a valid username and password.
- VS Code version 1.82 or later is installed. Older versions may not support the Copilot proxy setting.
- GitHub Copilot extension is installed and signed in.
Method 1: Configure Proxy in VS Code settings.json for Copilot Only
This method sets the proxy only for the Copilot extension. Other extensions and VS Code features will use the default network settings.
- Open VS Code settings.json
Press Ctrl+Shift+P to open the Command Palette. TypePreferences: Open Settings (JSON)and press Enter. This opens the settings.json file for the current user. - Add the Copilot proxy setting
Paste the following JSON object inside the curly braces. Replacehttp://proxy.example.com:8080with your proxy URL. If you need authentication, include it as shown in the next step."github.copilot.advanced": {
"proxy": "http://proxy.example.com:8080"
} - Add proxy authentication if required
If your proxy requires a username and password, include them in the URL format:http://username:password@proxy.example.com:8080. Replaceusernameandpasswordwith your credentials. Save the file with Ctrl+S. - Restart VS Code
Close all VS Code windows and reopen. The Copilot extension will now use the configured proxy. Test by typing a comment like// function to calculate sumand waiting for suggestions.
Method 2: Configure Proxy Using Environment Variables
This method sets the proxy system-wide. All VS Code extensions and other applications that respect HTTP_PROXY and HTTPS_PROXY will use it. This is useful if you have multiple tools behind the same proxy.
On Windows 10 and Windows 11
- Open System Properties
Press Windows+R, typesysdm.cpl, and press Enter. Go to the Advanced tab and click Environment Variables. - Add HTTP_PROXY and HTTPS_PROXY
Under User variables, click New. For Variable name enterHTTP_PROXY. For Variable value enter your proxy URL, for examplehttp://proxy.example.com:8080. Click OK. Repeat forHTTPS_PROXYwith the same value. - Add NO_PROXY for local addresses
Create a third variable namedNO_PROXYwith valuelocalhost,127.0.0.1. This prevents Copilot from trying to reach local addresses through the proxy. - Restart VS Code and your terminal
Close all VS Code windows and any open command prompts. Reopen VS Code. Copilot will read the environment variables automatically.
On macOS and Linux
- Edit your shell profile
Open a terminal. Runnano ~/.zshrcornano ~/.bashrcdepending on your shell. - Add proxy exports
Add these lines at the end of the file:export HTTP_PROXY="http://proxy.example.com:8080"export HTTPS_PROXY="http://proxy.example.com:8080"export NO_PROXY="localhost,127.0.0.1"
Save with Ctrl+O, then exit with Ctrl+X. - Reload the profile
Runsource ~/.zshrcorsource ~/.bashrc. - Launch VS Code from the terminal
Typecodein the terminal to start VS Code. Copilot will use the environment variables.
Method 3: Configure Proxy in VS Code General Settings
VS Code has a general proxy setting that applies to all extensions except those with their own override. Copilot respects this setting if you have not set the Copilot-specific proxy.
- Open VS Code Settings UI
Press Ctrl+, to open Settings. In the search bar, typeproxy. - Set the proxy URL
Look for the setting Http: Proxy. Enter your proxy URL, such ashttp://proxy.example.com:8080. If you need authentication, include it in the URL. - Set proxy strict SSL
Below the proxy URL, find Http: Proxy Strict SSL. Set it to false if your proxy uses a self-signed certificate. Otherwise leave it true. - Save and restart VS Code
Close and reopen VS Code. Copilot will now use the general proxy setting.
If Copilot Still Fails to Connect After Proxy Configuration
Copilot Returns Connection Timeout or DNS Errors
The proxy server address or port may be incorrect. Verify the proxy URL by testing it with a browser or curl. For example, open a terminal and run curl -x http://proxy.example.com:8080 https://api.github.com. If curl fails, the proxy is not reachable. Contact your network administrator for the correct proxy details.
Copilot Authentication Fails After Proxy Setup
If your proxy requires authentication, the credentials in the URL may be rejected. Special characters in the password must be URL-encoded. For example, replace @ with %40 and # with %23. Alternatively, use a password manager or environment variable that does not contain special characters. If you are using environment variables, the URL must be in the http://user:pass@proxy:port format.
Copilot Works in VS Code but Fails in Remote Tunnels or WSL
Remote development environments such as WSL, SSH, or Dev Containers have their own network stack. Configure proxy settings inside the remote machine using the same methods above. For WSL, set environment variables in the WSL Linux distribution. For SSH, set the proxy on the remote server. The VS Code proxy settings on your local machine do not apply to remote windows.
Proxy Setting Method Comparison: Environment Variables vs settings.json vs General Proxy
| Item | Environment Variables | Copilot-specific settings.json | General VS Code proxy |
|---|---|---|---|
| Scope | System-wide, all applications | Copilot extension only | All VS Code extensions |
| Authentication in URL | Supported | Supported | Supported |
| Requires restart | Yes, VS Code and terminal | Yes, VS Code | Yes, VS Code |
| Best for | Multiple tools behind same proxy | Isolating Copilot proxy from other extensions | Simple proxy without per-extension needs |
You now have three ways to configure GitHub Copilot proxy settings in VS Code. Start with the Copilot-specific setting in settings.json if you only want to affect Copilot. Use environment variables if your entire development environment needs the proxy. If Copilot still fails, check the proxy authentication and test the proxy with curl. For remote development, configure the proxy inside the remote environment separately.