vscode
vscode copied to clipboard
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.
https://github.com/microsoft/vscode/blob/f8ae10c8d05cf92f55c19b4937f0a5c5c0498778/src/vs/server/node/server.cli.ts#L372-L376
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
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.70.0. Please try upgrading to the latest version and checking whether this issue remains.
Happy Coding!
Just got this on the latest version using $BROWSER in Codespaces. Reloading the window fixed the issue.
i'm seeing this consistently.
- I see it every time i use the
codecommand in the vscode terminal - i have the latest version
- i have tried deleting `~/.vscode-server/
- the temporary fix described above doesn't work for me
before I apply the 'fix'
Unable to connect to VS Code server: Error in request.
Error: connect EACCES /mnt/wslg/runtime-dir/vscode-ipc-596ebb83-bf0f-4710-ac8e-d6442b87d8a6.sock
at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) {
errno: -13,
code: 'EACCES',
syscall: 'connect',
address: '/mnt/wslg/runtime-dir/vscode-ipc-596ebb83-bf0f-4710-ac8e-d6442b87d8a6.sock'
}
output when i apply the 'fix'
$ VSCODE_IPC_HOOK_CLI=$( lsof | grep $UID/vscode-ipc | awk '{print $(NF-1)}' | head -n 1 )
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/acpid/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/acpid/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/allowlist/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/allowlist/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/binfmt/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/binfmt/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/container-filesystem/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/container-filesystem/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/devenv-service/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/devenv-service/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/diagnose/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/diagnose/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/dns-forwarder/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/dns-forwarder/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/docker/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/docker/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/http-proxy/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/http-proxy/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/kmsg/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/kmsg/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/nat/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/nat/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/rngd/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/rngd/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/sntpc/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/sntpc/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/socks/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/socks/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/syn-filter/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/syn-filter/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/trim-after-delete/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/trim-after-delete/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/volume-contents/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/volume-contents/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/vpnkit-forwarder/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/vpnkit-forwarder/rootfs
Output information may be incomplete.
lsof: WARNING: can't stat() tmpfs file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/vpnkit-tap-vsockd/tmp
Output information may be incomplete.
lsof: WARNING: can't stat() overlay file system /mnt/wsl/docker-desktop-data/version-pack-data/community/mount-services-cache/entries/services.tar/eae320734be940e610955446282e0484c6d4bc072f63eb699ff02f3f1dadef28/containers/services/vpnkit-tap-vsockd/rootfs
Output information may be incomplete.
and when i run the command again-
Command is only available in WSL or inside a Visual Studio Code terminal.
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
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 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:
$ code FILE
Unable to connect to VS Code server: Error in request.
Error: connect ENOENT /run/user/1000/vscode-ipc-cae625be-217b-4eb3-b699-7043b7a7a557.sock
at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) {
errno: -2,
code: 'ENOENT',
syscall: 'connect',
address: '/run/user/1000/vscode-ipc-cae625be-217b-4eb3-b699-7043b7a7a557.sock'
}
$ ls -l /run/user
total 0
$ lsof | grep $UID/vscode-ipc | wc -l
0
not sure if relevant, but "Extension Host (Remote)" contains:
2023-04-15 10:56:10.729 [error] Error: listen EACCES: permission denied /run/user/1000/vscode-ipc-6241cd78-b726-4f61-b6bc-3966bc57ace9.sock
at Server.setupListenHandle [as _listen2] (node:net:1313:21)
at listenInCluster (node:net:1378:12)
at Server.listen (node:net:1476:5)
at O.g (/home/piersh/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/api/node/extensionHostProcess.js:101:188356)
at new v (/home/piersh/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/api/node/extensionHostProcess.js:101:188271)
at new O (/home/piersh/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/api/node/extensionHostProcess.js:101:190361)
at S.j (/home/piersh/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/api/node/extensionHostProcess.js:84:1296)
at S.createInstance (/home/piersh/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/api/node/extensionHostProcess.js:84:788)
at E.pb (/home/piersh/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/api/node/extensionHostProcess.js:120:12418)
at E.initialize (/home/piersh/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/api/node/extensionHostProcess.js:111:8811)
at new d (/home/piersh/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/api/node/extensionHostProcess.js:115:1338)
at c (/home/piersh/.vscode-server/bin/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/out/vs/workbench/api/node/extensionHostProcess.js:125:18641)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
wsl guest is CentOS7. systemd is NOT running. /run/user is empty.
it looks like vscode is incorrectly assuming the existence of some systemd-created directories.
creating the missing directory is a workaround for me:
sudo mkdir -p /run/user/$UID
sudo chown $UID /run/user/$UID
another option may be to ensure that the environment variable XDG_RUNTIME_DIR points to some directory you own.
I run a python script permanently with nohup python script.py & and inside my nohup.out file i consistenly see this error and my script stops running which is very frustrating. Tried the temporary fix and alsoclearing the cache files in vs-code folder as suggested here. I will come back in a week to say if the error still occurs.
EDIT: This seemed to fix my error, the error no longer happens :+1:
creating the missing directory is a workaround for me: sudo mkdir -p /run/user/$UID sudo chown $UID /run/user/$UID
This unfortunately isn't an option when one does not have write access to /run/user/, such as when working on a supercomputer. This is really a bummer since this means it is not possible to connect to a vscode running on an interactive job, such as for example to debug a heavy program. If anyone has any suggestions I'd be glad to hear them.
Running on the latest vscode version (1.842.2) and still seeing this issue. As setting VSCODE_IPC_HOOK_CLI doesn't work for me, this is getting pretty unworkable.
Update: the below works, but I found after a restart having to often re-run the commands. See @mx-bernhard's solution below https://github.com/microsoft/vscode/issues/157275#issuecomment-1890408573
sudo mkdir -p /run/user/$UID
sudo chown $UID /run/user/$UID
This did the trick for me on WSL2.
Thanks, @Spongman
Update
That (the above commands) also worked for me! Great work
Above 2 commands don't work for me :|
Nor does VSCODE_IPC_HOOK_CLI=$( lsof | grep $UID/vscode-ipc | awk '{print $(NF-1)}' | head -n 1 )
:(
Happens 100% of time. Would be happy to provide any logs or whatever needed :) WSL2 Ubuntu 22.04.3 LTS
My issue was not this issue but rather that other alleged "duplicate" which, for some reason, got closed.
Good news: This absolutely works!
export VSCODE_IPC_HOOK_CLI=$(lsof | grep $USER | grep vscode-ipc | awk '{print $(NF-1)}' | head -n 1)
- Check your
VSCODE_IPC_HOOK_CLIcontents before and after to see what kind of difference it makes. - Make sure to run it in the right environment.
@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 ~/.profile or something? 🤔
Edit: Nvm, it doesn't work for me no matter where and how I use it
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 in XDG_RUNTIME_DIR and is used by vs code:
loginctl enable-linger $(whoami)
After that I can observe on a freshly booted Ubuntu-Distro (wsl --shutdown in a windows-cmd and open new ubuntu shell), that /user/run/1000 exists and is already filled with some files in my case (I have wayland installed). This was not the case before that loginctl command.
Now I can execute code from within vs code just like I could without systemd.
It's alive! Thank you @mx-bernhard Works like charm
@mx-bernhard that is brilliant! Thanks so much.
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:loginctl enable-linger $(whoami)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've had this problem for ages. this immediately fixed it! Thanks so much.
@mx-bernhard Thanks!!! 👏
Using Remote - SSH after deleting all the forwarded ports I was receiving the error above. Running the VSCode command ">Remote-SSH: Kill VS Code Server on Host" resolves my issue.
@mx-bernhard It solved my issue for months. Thank you so much! 👏
@mx-bernhard wow, It worked for me Thank you so much
My issue was not this issue but rather that other alleged "duplicate" which, for some reason, got closed.
Good news: This absolutely works!
export VSCODE_IPC_HOOK_CLI=$(lsof | grep $USER | grep vscode-ipc | awk '{print $(NF-1)}' | head -n 1)
- Check your
VSCODE_IPC_HOOK_CLIcontents before and after to see what kind of difference it makes.- Make sure to run it in the right environment.
lsof was quite slow in my dev container (>20s) so I modified this script slightly and now it runs in ~1s
export VSCODE_IPC_HOOK_CLI=$(lsof +D /tmp/ | grep $USER | grep vscode-ipc | awk '{print $(NF-1)}' | head -n 1)
@mx-bernhard wow, It worked for me Thank you so much!!!!