billy
billy

Reputation: 1493

Visual Studio Code: Trying setup Remote Debugging to AWS Ec2 Instance?

So I am trying to setup remote debugging from my local machine to ec2 instance on Visual Studio Code. Getting an error:

launch.json file

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach to Remote",
            "address": "ec2..........-west-2.compute.amazonaws.com",
            "port": 3000,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/home/ubuntu/"
        }

    ]
}

ERROR:

Debugging with inspector protocol because Node.js version could not be determined (Error: connect ECONNREFUSED 52.182.32.72:3000)

Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 54.186.38.77:3000).

Additionally

  1. In order to connect VS Code with ec2 do i need to set up a project folder inside it first?
  2. For this to work do I need to install nodejs as well ON EC2 First?

What am I doing wrong? Please help!

Upvotes: 0

Views: 2094

Answers (1)

Riswan
Riswan

Reputation: 374

To connect EC2 from VS Code you need to install sftp extension.

  1. Open the VS Code then type Ctrl + Shift + X then it will open extensions window
  2. type "sftp" in the extension window then click the first extension developed by "liximomo"
  3. Press Ctrl + Shift + P then type SFTP:Config
  4. In the opened config json file edit "host" and "privateKeyPath" according to your EC2 like below

{

"name": "GIVE ANY NAME",
"host": "ec2-.........compute.amazonaws.com",
"protocol": "sftp",
"port": 22,
"username": "ec2-user",
"privateKeyPath": "SPECIFY YOUR PATH/FILENAME.pem",
"remotePath": "/",
"uploadOnSave": true

}

  1. Save the sftp.json file and click the Remote Explorer Button added in the left menu bar of VS Code, in the file explorer you can se the remote folders and files

Upvotes: 2

Related Questions