Visual Studio Code unable to connect

Posted on Fri 21 April 2023 in Visual Studio Code • Tagged with Visual Studio Code, VS Code

Some times, I get this error:

Unable to connect to VS Code server: Error in request.
Error: connect ENOENT [...]

I always have to search for the solution, so I decided to write it down here. From this issue, I found that running this solves the problem:

VSCODE_IPC_HOOK_CLI=$(lsof | grep $USER | grep vscode-ipc | awk '{print $(NF-1)}' | head -n 1)