HomeVS Code / Dev Env【VS Code・WSL】「VS Code Server for WSL closed unexpectedly」の解消法
VS Code / Dev Env ⚠ 古い情報の可能性

【VS Code・WSL】「VS Code Server for WSL closed unexpectedly」の解消法 This article explains how to resolve the 'VS Code Server for WSL closed unexpectedly' erro…

元記事を読む 古い情報の可能性
AI 3 行サマリ
  • Windows 10環境でVS CodeからWSLにリモート接続する際に発生する「VS Code Server for WSL closed unexpectedly」エラーの原因と解決策を紹介。
  • WSL(非WSL2)とUbuntu 20.04 LTSの組み合わせで確認された事例をもとに手順を解説している。
English summary
  • This article explains how to resolve the 'VS Code Server for WSL closed unexpectedly' error that occurs when connecting to WSL from VS Code on Windows 10.
  • The fix is based on a confirmed case using WSL (not WSL2) with Ubuntu 20.04.6 LTS and VS Code 1.122.1.

VS CodeのリモートWSL機能は、Windows上からLinux環境を透過的に扱える便利な仕組みだが、環境によっては接続時に「VS Code Server for WSL closed unexpectedly」というエラーが表示されて起動に失敗することがある。本記事が対象とするのは、Windows 10・VS Code 1.122.1・WSL(WSL2ではない旧来のWSL1)・Ubuntu 20.04.6 LTSという構成で発生した事例だ。

WSL1とWSL2は名称こそ似ているが、アーキテクチャは大きく異なる。WSL2はHyper-Vベースの軽量仮想マシン上で本物のLinuxカーネルを動かすのに対し、WSL1Windowsカーネルのシステムコール変換レイヤーで動作する。そのため、VS Codeが内部で使用するサーバープロセスの動作条件もWSL1とWSL2では差異が生じやすく、特定バージョンのVS Code Serverがうまく起動しないケースが報告されている。

エラーの原因として多く挙げられるのは、VS Codeが~/.vscode-serverディレクトリにインストールしたサーバーバイナリが破損・不整合な状態になっているケースだ。解決の定番アプローチは、このディレクトリをWSL側から削除し、VS Codeに再インストールさせることである。具体的にはWSLターミナルでrm -rf ~/.vscode-serverを実行したのち、VS CodeのRemote - WSL拡張機能から再接続を試みる。

Windows 10環境でVS CodeからWSLにリモート接続する際に発生する「VS Code Server for WSL closed unexpectedly」エラーの原因と解決策を紹介。
🔷 VS Code / Dev Env · 本記事のポイント

また、VS Code本体や拡張機能のバージョンとサーバーバイナリのバージョン不一致が原因となる場合もあるため、VS Code自体を最新版にアップデートすることも有効な手段として挙げられる。さらに、WSL1固有の制限としてinotifyやソケット関連の動作に制約があり、一部のVS Code Server機能がWSL1では正常に動作しないという根本的な問題も存在する。長期的な安定稼働を求めるならWSL2への移行が推奨される。

Remote Development系の拡張機能はMicrosoftが積極的にアップデートを重ねており、新バージョンのVS Codeが旧来のWSL1環境を暗黙的にサポート対象外とするケースも今後増えていく可能性がある。WSL1を意図的に使い続けている場合は、VS Codeのバージョンアップに伴う互換性の変化に注意を払っておく必要があるだろう。同様のエラーはDocker Desktop経由のRemote Containers環境やSSHリモート接続でも類似のメカニズムで発生することがあり、~/.vscode-serverの再生成という対処法は汎用性が高い。

VS Code's Remote - WSL extension is a powerful feature that lets developers work inside a Linux environment directly from the Windows editor. But on certain setups, connecting to WSL can fail immediately with the message 'VS Code Server for WSL closed unexpectedly.' The case documented in this article involves Windows 10, VS Code 1.122.1, legacy WSL (WSL1, not WSL2), and Ubuntu 20.04.6 LTS — a combination that highlights some of the compatibility friction that still exists in this toolchain.

WSL1 and WSL2 are fundamentally different under the hood. WSL2 runs a real Linux kernel inside a lightweight Hyper-V virtual machine, while WSL1 relies on a translation layer that maps Linux system calls to Windows kernel equivalents. This architectural gap means that server-side processes launched by VS Code can behave differently — or fail outright — depending on which WSL version is in use. The VS Code Server binary must be installed and executed inside the Linux environment, and any inconsistency in that binary can surface as an unexpected shutdown.

The most common fix is straightforward: delete the ~/.vscode-server directory from within WSL and let VS Code reinstall it fresh on the next connection attempt. Running rm -rf ~/.vscode-server in a WSL terminal clears out any corrupted or mismatched server binaries. Once removed, reopening a WSL-connected window in VS Code triggers an automatic reinstallation of the correct server version.

A version mismatch between the VS Code client and the server binary is another frequent culprit. If VS Code was updated on the Windows side without a corresponding server refresh on the WSL side, the startup handshake can fail. Keeping VS Code up to date and performing a clean reinstall of the server directory typically resolves this.

This article explains how to resolve the 'VS Code Server for WSL closed unexpectedly' error that occurs when connecting to WSL from VS Code on Windows 10.
🔷 VS Code / Dev Env · Key takeaway

It is worth noting that WSL1 carries inherent limitations around inotify events, Unix socket handling, and other low-level interfaces that VS Code Server relies on. Some features simply do not work as expected under WSL1, and Microsoft's documentation increasingly steers users toward WSL2. While WSL2 requires enabling virtualization and carries slightly more overhead, the stability gains for development tooling are significant.

Beyond WSL, the ~/.vscode-server cleanup approach is broadly applicable. Similar errors appear in Remote - SSH and Dev Containers setups when server binaries become stale or corrupted. As VS Code continues to evolve rapidly, users on older or less common configurations — like WSL1 — should watch for compatibility changes with each major release. The safest long-term path for anyone hitting repeated WSL connection issues is migrating to WSL2, which benefits from better kernel compatibility and ongoing first-class support from both Microsoft and the broader open-source tooling ecosystem.

  • SourceQiita VSCode tagT2
  • Source Avg ★ 1.3
  • Typeブログ
  • Importance ★ 情報 (lower priority in VS Code / Dev Env)
  • Half-life 📘 中期 (チュートリアル)
  • LangJA
  • Collected2026/06/04 03:00

本ページの本文・要約は AI による自動生成です。正確性は元記事 (qiita.com) をご確認ください。

🔷 VS Code / Dev Env の他の記事 もっと見る →

URL をコピーしました