GitHub Copilot in VS Code With WSL: Connection Troubleshooting
🔍 WiseChecker

GitHub Copilot in VS Code With WSL: Connection Troubleshooting

You are using Visual Studio Code with the Windows Subsystem for Linux and GitHub Copilot stops suggesting code or shows connection errors. This usually happens because Copilot cannot reach its backend servers or the local extension proxy fails inside the WSL environment. The issue is not a WSL network problem but a mismatch between how Copilot authenticates and how VS Code routes traffic through the WSL gateway. This article explains the root cause and provides step-by-step fixes to restore Copilot suggestions in your WSL workspace.

Key Takeaways: Restoring Copilot Connections in WSL

  • VS Code Remote Extension (ms-vscode-remote.remote-wsl): Must be installed and updated to version 0.79 or later for proper Copilot proxy handling.
  • Copilot extension on the remote WSL side: Must be explicitly installed inside the WSL environment, not only on the Windows host.
  • Copilot: Sign Out and Sign In command: Run this from the VS Code command palette while connected to WSL to refresh the authentication token.

Why Copilot Loses Connection in WSL

When you open a WSL folder in VS Code, the Remote – WSL extension starts a VS Code server inside the Linux distribution. GitHub Copilot runs as a language server in that remote context. The Copilot extension on the Windows host and the one inside WSL are separate instances. If the remote instance does not have a valid authentication token or cannot reach the Copilot API endpoints, it fails silently. The most common root cause is that the Copilot extension is only installed on the Windows side and not propagated to the WSL server. A secondary cause is a stale token that the remote instance cannot refresh because of proxy or firewall rules on the WSL network interface.

Network Path Differences

The WSL network stack is a virtualized adapter. Traffic from VS Code inside WSL routes through the Windows host’s network. If a corporate proxy or VPN is configured on the Windows side, Copilot requests originating from WSL may not pass through that proxy automatically. The Copilot extension does not read the WSL environment’s proxy variables by default. This mismatch causes timeouts and authentication failures.

Extension Version Mismatch

If the Copilot extension version on the Windows host differs from the version installed in the WSL remote server, the communication protocol may break. VS Code Remote extensions auto-update on the host but the remote server may lag behind until you reload the window or restart the WSL instance.

Steps to Fix Copilot Connection in WSL

Follow these steps in order. Test Copilot after each step by typing a comment such as // test copilot in a code file and waiting for a suggestion. Do not skip the sign-out step even if you are already signed in.

  1. Update the Remote – WSL extension
    Open VS Code on Windows. Go to the Extensions view. Search for Remote – WSL by Microsoft. If an update is available, click the Update button. Reload the VS Code window after the update. This ensures the extension supports the latest Copilot proxy protocol.
  2. Install GitHub Copilot extension inside WSL
    In VS Code, open a WSL folder. Open the Extensions view. You will see a section labeled LOCAL – INSTALLED and a section labeled WSL:UBUNTU or your distribution name. If Copilot appears only under LOCAL, click the Install in WSL button next to the Copilot extension. Wait for the installation to finish. Reload the window.
  3. Sign out and sign in to Copilot
    Press Ctrl+Shift+P to open the command palette. Type Copilot: Sign Out and select it. Wait for the confirmation message. Open the command palette again and type Copilot: Sign In. Follow the browser-based authentication flow. This forces the remote instance to get a fresh token.
  4. Restart the VS Code Remote Server
    Open the command palette with Ctrl+Shift+P. Type Remote: Kill VS Code Server on Host. Confirm the action. Close VS Code completely. Reopen VS Code and open your WSL folder. The remote server restarts fresh and loads the correct Copilot extension.
  5. Configure proxy settings for WSL
    If you use a corporate proxy, open the WSL terminal and set environment variables: export HTTP_PROXY=http://proxy.yourcompany.com:8080 and export HTTPS_PROXY=http://proxy.yourcompany.com:8080. Add these lines to your ~/.bashrc or ~/.zshrc file. Reload the terminal with source ~/.bashrc. Then restart VS Code.
  6. Check the Copilot output channel
    Open VS Code and go to View > Output. In the dropdown at the top right, select GitHub Copilot. Look for error messages such as Failed to connect or Token refresh failed. If you see a timeout error, the proxy or firewall is blocking the connection. If you see an authentication error, repeat steps 3 and 4.

If Copilot Still Has Issues After the Main Fix

The following issues may persist even after you complete the main steps. Each has a specific cause and a targeted fix.

Copilot Suggests Only in Local Files but Not in WSL Files

This means the Copilot extension is installed only on the Windows side. When you open a WSL folder, VS Code runs a separate server that does not include Copilot. Go to the Extensions view while connected to WSL and verify that Copilot appears under the WSL section. If it does not, click the Install in WSL button. This is the most common oversight.

Copilot Shows a Spinning Icon and Never Responds

The remote server cannot reach the Copilot API. Open a terminal inside WSL and run curl -I https://api.github.com/copilot. If the command hangs or returns a connection refused error, the WSL network interface is blocked. Check your Windows firewall rules and corporate VPN configuration. Add an exception for the WSL virtual adapter. Restart the WSL service with wsl --shutdown in a Windows command prompt, then reopen VS Code.

Copilot Returns Authentication Error After Windows Sleep or Hibernate

The authentication token cached in the WSL remote server expires while the host is sleeping. The remote server does not automatically refresh the token when the host wakes up. Open the command palette and run Copilot: Sign Out, then Copilot: Sign In. This refreshes the token without restarting the whole server.

Copilot Works on Windows Host but Not in WSL with Docker

If you use VS Code’s Dev Containers extension inside WSL, the Copilot extension must be installed inside the container as well. Open the Extensions view while attached to the container and install Copilot there. The container does not inherit extensions from the WSL server automatically.

GitHub Copilot Connection Methods: WSL Remote vs Local Windows vs Dev Container

Item WSL Remote Local Windows Dev Container
Extension install location WSL server instance Windows host Container instance
Proxy configuration needed WSL environment variables Windows system proxy Container environment variables
Token refresh method Copilot: Sign Out/In in WSL Copilot: Sign Out/In on host Copilot: Sign Out/In in container
Common failure pattern Extension not installed remotely Firewall blocking API Missing extension in container

Now you can restore GitHub Copilot suggestions in your WSL workspace. Start by verifying the extension is installed on the remote side and then sign out and sign in to refresh the token. For persistent proxy problems, set the HTTP_PROXY and HTTPS_PROXY variables in your WSL shell profile. If you use multiple WSL distributions, repeat the extension installation for each distribution separately.