The Sneaky Setting That Kept Disconnecting My SSH Connection On VS Code

VS Code SSH connection playing hide and seek? You're not alone! I battled random disconnects until I found the culprit: a sneaky setting called "Remote.SSH: Use Exec Server". Curious how to fix it? Check out my full post and say goodbye to SSH headaches!

The Sneaky Setting That Kept Disconnecting My SSH Connection On VS Code

Hey there, fellow code warriors! Today, I'm gonna spill the beans on a frustrating problem I had with VS Code's Remote Explorer extension. If you've ever found yourself pulling your hair out because your SSH connection keeps dropping like a bad habit, buckle up - this one's for you!

The Symptoms

So picture this: There I was, coding away like a boss on my remote server through VS Code. Everything's going swimmingly, and then BAM! Disconnected. Again. And again. It was like playing whack-a-mole with my SSH connection, and let me tell you, it was NOT fun.

SSH connection suddenly disconnecting


At first, I thought maybe my internet was just being a jerk. I blamed everything. I even spoke to my hosting's support team for Days telling them it must be something from their side that's at fault because when I'm connecting to a different server it's not disconnection like this.

Shoutout to knowhost's support for being understanding

I also tried using another PC and the same thing happened. So what gives?

The Hunt Begins

I started digging around like a digital detective, looking for clues. Was it my SSH config? Nah, that was straight forward to configure. Maybe VS Code needed an update? Nope, already on the latest release.

Then, just when I was about to throw in the towel and go back to coding on a stone tablet, I stumbled upon the culprit. And boy, was it a sneaky one.

The Eureka Moment: Remote.SSH: Use Exec Server

Turns out, there's this little setting in VS Code called "Remote.SSH: Use Exec Server". Sounds innocent enough, right? WRONG. This bad boy was the source of all my troubles.

Here's the deal: When this setting is enabled, VS Code tries to use a separate "exec" server for running commands on the remote machine (I mean that's what I understand anyway). In theory, this is supposed to make things faster and more reliable. In practice? Well, let's just say it was about as reliable as a chocolate teapot.

The Fix

Ready for the mind-blowing solution? Here it is:

  1. Open VS Code settings
  • On Windows/Linux: File > Preferences > Settings (or use the shortcut Ctrl + ,)
  • On Mac: Code > Settings > Settings (or use the shortcut Cmd + ,)
  1. Search for "Remote.SSH: Use Exec Server"
  2. Uncheck that box faster than you can say "Why didn't I find this sooner?"

And voila! Just like magic, my SSH connections became rock-solid. No more random disconnects, no more pulling my hair out, no more contemplating a career change to goat farming.

The Takeaway

When you find that one setting that's been causing you grief and fix it? That feeling is better than finding the last slice of pizza in the box.

So if you're battling with SSH disconnects in VS Code, give this a shot. It might just save your sanity (and your hairline).

Happy coding, folks!