7

I connect to the remote server with vs code command invoked by CTRL+SHIFT+P Remote-SSH: Connect to Host.... Everything works fine. After some time when I try to open a new file from the vs-code terminal with the code command, I will get this error message:

/some/path/on/remote$ code some_existing_file.py                                                                                         
Unable to connect to VS Code server: Error in request.
Error: connect ENOENT /run/user/1006/vscode-ipc-789269cc-6026-4d15-8ca6-<i_changed_this>.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'connect',
  address: '/run/user/1001/vscode-ipc-789269cc-6026-4d15-8ca6-<i_changed_this>.sock'
}

Killing all running vs-code processes manually "solves" the problem. The occurence of this problem seems to be random. Sometimes it happens 3 times within an hour, sometimes just once per day.

vs-code version: 1.66.0

Any suggestion on how to solve this issue?

3
  • why use the terminal to open a file Commented Apr 6, 2022 at 9:14
  • 1
    @rioV8 Too lazy to click. I hate using the file explorer GUI in general when I can use terminal as unified interface. Especially when you are browsing nested folders, TAB autocomplete is helpful. Commented Apr 6, 2022 at 11:16
  • 1
    you can use Ctrl+P and type part of the filename, or Ctrl+O, or Ctrl+Shift+E and type part of the filename, you have to enable workbench.list.keyboardNavigation Commented Apr 6, 2022 at 14:04

3 Answers 3

2

I was having similar issue and error message when running code .

The solution worked for me was to remove everything under the HOME's .vscode-server directory

rm -rf ~/.vscode-server

Now do the code xxx command again should re-install the VS Code Server under the .vscode-server folder.

Sign up to request clarification or add additional context in comments.

2 Comments

I did this, and it removed all of the extensions/settings I had configured for the remote connection. The "code" command worked immediately afterwards, but it doesn't work today (I deleted the .vscode-server yesterday). I would prefer not having to reinstall my extensions each time; do you have any advice for that?
The answer from Yu Sun works without removing settings & extensions
1

It's caused by the client connecting to an outdated socket. To simply solve this, just SSH into the server, and kill all processes for VS code:

ps -fu $USER | grep vscode | grep -v grep | awk '{print $2}' | xargs kill

Then you can restart VS code (with remote SSH) and try again.

1 Comment

This worked wonders, thanks a lot.
0

Can you try this hack in your .bashrc or any other bash setup script you are using:

if [[ ! -z VSCODE_IPC_HOOK_CLI ]]; then
    REMOTE_CODE_BIN_PATH=$(echo $PATH | tr ':' '\n' | grep "/Users/steelphase/.vscode-server/bin/.*/bin")
    if [[ -d $REMOTE_CODE_BIN_PATH ]]; then
        NEW_PATH=$(echo $PATH | sed -e "s~:$REMOTE_CODE_BIN_PATH~~g")
        export PATH="$REMOTE_CODE_BIN_PATH:$NEW_PATH"
    fi
fi

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.