vscode: Unable to connect to VS Code server: Error in request - ENOENT /run/user/1000/vscode-ipc-*.sock
This issue was originally reported in microsoft/vscode-remote-release#6997, but the cause was narrowed down to a file in this repo, src/vs/server/node/server.cli.ts.
Summary:
I’m occasionally but regularly seeing this error when using Remote SSH and running the code command in the built-in terminal.
Unable to connect to VS Code server: Error in request.
Error: connect ENOENT /run/user/1000/vscode-ipc-5cc265b0-6bec-4e0e-99c7-8fc48bccd7c4.sock
at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
errno: -2,
code: 'ENOENT',
syscall: 'connect',
address: '/run/user/1000/vscode-ipc-5cc265b0-6bec-4e0e-99c7-8fc48bccd7c4.sock'
}
Here’s a temporary fix.
VSCODE_IPC_HOOK_CLI=$( lsof | grep $UID/vscode-ipc | awk '{print $(NF-1)}' | head -n 1 )
It searches for the first available VSCode IPC socket, gets its second to last column for the path to vscode-ipc-*.sock, and updates the relevant env variable.
After running the above line, the error no longer occurs.
It means the error is caused by that environment variable having a “stale” value, pointing at an old socket process which no longer exists.
The env variable is passed to the http module for the option socketPath. When it’s an invalid value, http.request throws, “Error in request - ENOENT”.
The permanent solution seems to be: to check if VSCODE_IPC_HOOK_CLI is pointing to a living socket process, and if needed, refresh the value with the path to an available one.
- VSCode Version: 1.69.2
- Local OS Version: Darwin x64 18.2.0
- Remote OS Version: Ubuntu 22.04 LTS
- Remote Extension/Connection Type: SSH
Steps to Reproduce:
The error appears occasionally, maybe after host reboots or when Remote SSH reconnects.
- Open new window with Remote SSH
- Open terminal with CTRL/CMD+J
- Run
code some-file.txt
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 16
- Comments: 18
Since I only have the issue in my Ubuntu 22.04 WSL environment and only when systemd is enabled, this superuser answer helped me to fix the missing
/run/user/1000-dir (or whatever your user’s id may be) which is stored inXDG_RUNTIME_DIRand is used by vs code:After that I can observe on a freshly booted Ubuntu-Distro (
wsl --shutdownin a windows-cmd and open new ubuntu shell), that/user/run/1000exists and is already filled with some files in my case (I have wayland installed). This was not the case before thatloginctlcommand.Now I can execute
codefrom within vs code just like I could without systemd.I have just started seeing this when connected to wsl guests. I’m up-to-date (1.77.3). I have tried deleting
~/.vscode-server*while vscode is not running. doesn’t fix it.in vscode wsl terminal:
not sure if relevant, but “Extension Host (Remote)” contains:
wsl guest is CentOS7.
systemdis NOT running./run/useris empty.it looks like vscode is incorrectly assuming the existence of some systemd-created directories.
creating the missing directory is a workaround for me:
another option may be to ensure that the environment variable
XDG_RUNTIME_DIRpoints to some directory you own.@Domiii do I need to run it every time it breaks for me?
Which is literally every time I write something to VSCode terminal
Or can I slap it to
~/.profileor something? 🤔Edit: Nvm, it doesn’t work for me no matter where and how I use it
I run ssh remote into a Linux system to use VSCode, occasionally run into this problem as well: typing in th terminal something like
code some_file, the file is not opened in current VSCode, but the error message like “Error: connect ENOENT” shows. Usually after restarting VSCode the problem disappears.Removing ~/.vscode-server is not a viable option, this directory usually has data larger than 1GB.
i’m seeing this consistently.
codecommand in the vscode terminalbefore I apply the ‘fix’
output when i apply the ‘fix’
and when i run the command again-
so that’s… something.
not sure who invited docker-desktop to the party.
for context- I first saw this after migrating to the Windows Store WSL2