VSCode unable to connect SSH to raspberry pi 4 - visual-studio-code

I'm facing an annoying problem which just popped out of the blue overnight: VScode will not, under any circumstances connect to my raspberry pi 4 via ssh. I'm using VScode insiders with the remote-ssh extension and it worked like a charm the weeks before.
What works:
Putty connects seamlessly over LAN or WiFi.
ssh is enabled on rpi4
i am using the correct IP which i get from hostname -I in the terminal
What doesn't work:
neither "raspberrypi" nor "my correct IP" work. Right after selecting "Linux" in the selection process it throws the error "Could not establish connection to "my correct IP""
uninstalling VScode insiders and deleting all related files in docs and appdata changes nothing after reinstallation
What i observed:
This happened to me before in VScode for no reason and was unfixable. On a forum post someone recommended using insiders, which fixed the problem but now VScode insiders seems to be affected by this as well. Whenever a connection couldn't be established, two problems pop up in my extensions tab:
"Error while loading extensions. Error"
"We cannot conect to the Marketplace at this time, please try again later."
Especially the last one gives me a feeling that this is a bug within VScode. I'll gladly take the blame if it's on my behalf, i just want to fix the problem.
Similar things have been mentioned here:
"Extension host terminated unexpectedly" in vs code
Remote SSH in Visual Studio Code does not work
but are unsolved or don't quite fit my description. Thank you for your time and help.
Screenshot of my VScode insiders: https://imgur.com/a/uODtBlE

Related

Failed to connect to the remote extension host server (Error: Missing proxy instance MainThreadDebugService)

Hey stackoverflow community i have an issue with vscode connecting to wsl2 with the following error [picture bellow] message i already searched for hours and couldnt find a solution.
reinstalled both with a clean updated version without any success
Edit 1:Tried to unmount and remount folders also tried opening with high privilege's from cmd 'wsl code .' moreover i completely deleted wsl and vscode with all the extensions but still am getting the same error, i was able to reproduce more readable error, when opening a project it prompts with
unable to resolve resource vscode-re...://%ubuntu-22.04/file_path
Edit 2: opening WSL, 'New WSL window using distro' works fine but i cant open any directory, without it producing the error in Edit 1
I got the same issue. I use Windows and I open the folder in vscode in this way:
shift+right-click the folder -> open linux shell -> type in "code ."
when vscode opens, the error does not exist.
For me this was due to the secondary sidebar being visible.
After disabling it via View -> Appearance -> Secondary Side Bar, WSL2 starts up fine again.
I got the same.
If your project is on another drive mount it and
run vscode as administrator.
I had this issue and needed to run..
$ code
Updating VS Code Server to version 97dec172d3256f8ca4bfb2143f3f76b503ca0534
Removing previous installation...
Installing VS Code Server for x64 (97dec172d3256f8ca4bfb2143f3f76b503ca0534)
Downloading: 100%
Unpacking: 100%
Unpacked 2389 files and folders to /home/dmitri/.vscode-server/bin/97dec172d3256f8ca4bfb2143f3f76b503ca0534.
in WSL2 to update the WSL2 server. Then uninstalling and reinstalling the WSL extension from VSCode did the trick.
I am the same.
I also reinstalled VSCode and Docker, but nothing changed.
In the "Remote - Containers" tutorial, I was able to connect without any problems.
It doesn't work with my code.

vscode chrome attach unable to connect after some time

I have a really wired problem (or a bug) on vscode. I can "attach chrome" debugging totally fine usually,
but after some random time connecting to the chrome instance (may be a couple of hours or 8 hours, like I left it connected while I'm sleeping), it automatically disconnect the debugging,
then when I try to re-run attach chrome to reconnect it, for some weird reason it doesn't connect to the instance.
It's not a failed, it's not like "cannot connect to the port 9222", it's infinitely trying to connect showing the left up side blue indicator left to right.
This is my second time to encounter this weird problem. For the first time I even don't know how I solved the issue. maybe I just waited its reconnect for an hour or like that.
The first things I happened to think from the problem is simply its port conflict. So I checked vscode side's (I mean I use vscode in the remote ssh mode from Windows to Linux Ubuntu) port and process, used htop to filter port "9222" or process "chrome", but I didn't find anything stucking there. So I assume in the linux side the debugging process is exiting successfully.
So I did the same on the Windows side, I used resource monitor to check port "9222", no running process. If I re-open a 9222 debugging enable chrome, then it appears. closing, it disappears. It seems there is no problem here as well.
I then checked vscode's version. I was using vscode 1.64.2 so I side-installed 1.65.2 and 1.66.1 (the latest) and tested it. Doesn't work.
"refreshing the window" doesn't work. closing the window and re-open, doesn't work.
So what can I do?
Did you just install some new extensions in Visual Studio Code? I found that I had this exact same behaviour, "infinitely trying to connect showing the left up side blue indicator left to right", after I installed Karma Test Explorer and Test Explorer UI extensions. Once I uninstalled those extensions, debugging started working again.

What is the install terminal and how to remove it from VS Code terminal window?

This started showing up a few months back in my VS Code setup. It wasn't bothering so much, so I kept ignoring it. I am not sure what it's called, but searching around with "install window" or other combinations for VS Code gives some unexpected results. I am using remote-ssh extension for development and believe that it has something to do with a remote extension setting. If I try to close this window, my ssh connection breaks and VS Code opens up another of these to recreate the ssh connection.
I have tried checking and unchecking various remote-ssh extensions but to no avail. Even reinstalling VS Code didn't do any good. I don't see the same behavior on other machines that I have VS Code installed.
I would really appreciate if someone could help me get rid of this terminal. My VS Code is running on macos and ssh server is Ubuntu if this helps.
Remove "remote.SSH.showLoginTerminal": true from your User settings JSON file, then exit VSCode and re-launch the workspace. If that doesn't work set the setting to false instead.

Failed to connect to the remote extension host server (Error: Handler already set!)

I went to open a repo using Vs Code on a remote ssh host. I can ssh in successfully but when I try to open a repo I get Failed to connect to the remote extension host server (Error: Handler already set!). I've tried un installing and re installing Vs Code. Does anyone have a fix other than switching ides.
avenmore comment helped me:
I started getting this message with v1.57.0 when trying to run a Vue
project. Long story short: I usually have my DEBUG CONSOLE window
docked inside to the right of my TERMINAL (powershell), and upon
opening VSCode it wouldn't be visible and I'd get this message after
building successfully and trying to launch. The work-around is to
close VSCode, navigate to folder
USERPROFILE%\AppData\Roaming\Code\User\workspaceStorage and delete the
contents (notably state.vscdb) and then restart VSCode. The DEBUG
CONSOLE then shows itself again and all is fine unless I dock it again
and close VSCode and there is a good chance of it happening again next
time VSCode is opened. I have stopped docking the window inside the
terminal and it hasn't happened since.
For me what solved this was to go into the 'remote explorer' and clear out the SSH Targets that I already had in there before the upgrade, and then just paste them in again. Now I can connect. For example, a re-pasted SSH command looked like:
ssh -i "/Users/myuseraccount/abc.pem" someuser#ec2-ip-instance1.compute.amazonaws.com
A few days later this stopped working again. I think maybe because my SSH targets config saved what I pasted in as my SSH connection command. It appears "sometimes" if there are any entries in the SSH target config file, that this error occurs.
I find to ensure this error never occurs do
rm ~/.ssh/config
every time before you open Vs Code. Assuming ~/.ssh/config is where your Vs Code is reading its SSH entries from. There is one other place possible under /etc/$somewhere (I dont know where).
Then when you go to your empty SSH Target and hit the (+) button to connect, paste in the entire ssh connection request at the top of this file. I think you have to clear out the SSH targets every time otherwise I get this error coming up again days later.
Try in settings.json add item "security.workspace.trust.enabled": false
Windows, VSCode 1.57.1
I've just remove and added the host again in ssh configuration:
If you are using MacOS, I found a way.
Close Visual Studio Code, delete files in these two folder, then restart Visual Studio Code.
rm -rf $HOME/Library/Application\ Support/Code
rm -rf $HOME/.vscode
I tried all solution on this post, and can't get success. Then cloned another repo on my WSL folder then open, it was fine. So I changed my repo name, then problem gone. Maybe it may dumb solution. But it works me.
You gonna have to change the "debug.terminal.clearBeforeReusing" to true on setting.json. It works for me
I noticed there was a workspace folder in the folder above, deleted that and it resolved the issue
On the remote system, after various things had happened, I did mv .vscode .vscode-old to basically reset the remote .vscode (over ssh). I had also renamed the remote folder for the project -- not sure if that matters. Then I was was able to connect to it again.
I can't be scientific about those "various things that happened", but I'll to list some:
I had created a second project alongside the first and had connected to it - this was for unrelated reasons and preceded the "handler" error
it was then that I had issues connecting to the first one, even though it had worked for months and months without me ever having this Handler already set error -- related to creating the 2nd one? Not sure. The 2nd one worked fine throughout.
I tried File: Open Folder... from the second remote project and opened the first; it opened but got 2 python exception errors in a python extension - unfortunately I can't remember what they were. This could be noise / unrelated. I happen to have both MS python and pylance extensions installed remotely, I think it was the pylance once that was not happy.
during this, I had also renamed the 1st folder which didn't work; I'm not sure if the rename triggered the different behaviour ie python ext errors instead of the "handler" error
I then replaced .vscode in the first remote project (with the new folder name)
... and that was when it worked, with no "handler" error and no complaints from the python extension(s)

VS Code ssh remote is not opening file in new tabs

Recently vs code got updated and post that all files of remote server is opening in one tab only. Tab feature is working fine when opening files from local machine but when connected to remote server on ssh, only one file is opening. Tried many suggestions shown in online forums but nothing is working. Please help.
This was intermittent issue, i could not fix it but i found workaround for this while connected to remote servers. There is option to keep the tab open. Hope it helps anyone who is having similar issues.