解决 VSCode Remote-SSH/Copilot 在远程 Linux 上因 127.0.0.1:7890 代理报错的问题(完整排障记录)
适用场景:你在 本机 VSCode 需要代理(例如使用claude模型等),但通过 Remote-SSH 连接的远程 Linux 服务器并没有本地代理。VSCode Server/Copilot 在远端仍然尝试走 127.0.0.1:7890,导致联网失败、Copilot 激活失败。现象与日志
远端 ~/.vscode-server 的日志出现:
Error: Failed to establish a socket connection to proxies: PROXY 127.0.0.1:7890 GitHub Copilot could not connect to server. Extension activation failed [LanguageModelAccess] LanguageModel/Embeddings are not available without auth token 并能看到:
Can't use the Electron fetcher in this environment. Using the Node fetcher. 这说明 VSCode Server(Node 侧)在 远程服务器 上试图走 127.0.0.1:7890 的代理;但这个 127.0.0.1 指的是 远程机器的本地地址,不是你笔记本/台式机的本地地址,自然连不上。
TL;DR(一分钟快修)
你需要 区分本机与远端的代理配置:
- 本机 VSCode(GUI)继续走代理:
http.proxy = http://127.0.0.1:7890 - 远端 VSCode Server 不走代理:在「远端设置」里把
http.proxy设为空字符串
步骤:
- 连接到远程后,打开命令面板 → Preferences: Open Remote Settings (JSON),写入:
{ "http.proxy": "", "http.proxyStrictSSL": false } 2)(可选)在远端 shell 里清理代理环境变量:
unset http_proxy https_proxy all_proxy - 重启远端 VSCode Server(断开重连即可;如需彻底重置可执行
rm -rf ~/.vscode-server<