Attach to remote node app

I have been debugging my JQuery/Node.js app locally in Chrome with no problem. Now I'd like to attach to my Node.js app running in production.  I am following the direction to start my node app with --debug param but I keep getting connection refused on the host. How am I supposed to specify the host?  Or am I missing something completely and need to use SSH to make this work? 

 

Thank you.

0

You need using Attach to Node.js/Chrome run configuration to attach to a running Node.js process. See https://www.jetbrains.com/help/webstorm/2018.1/running-and-debugging-node-js.html#remote_debugging

note that Node debugger binds to 127.0.0.1 by default. You have to either provide a public IP address / 0.0.0.0, etc.in a command (like node --inspect=0.0.0.0:5858), or use port forwarding (ssh -L 8080:127.0.0.1:8080 <username>@<host> -N)

0

This is still not working.  I'm using node express and in my package.json I have the line: 

"main": "app.js --inspect=0.0.0.0:5858",

Then in Webstorm, in my Node.js.Chrome config I have the host set to 147.135.1.145 and the port set to 9229.

Clearly I'm still doing something wrong.

Thank you.
0

Host should be a public IP of the host you run your app on; port is the one you pass to Node in --inspect option - 5858 in your case. BTW, I'd recommend using --inspect-brk instead of --inspect, to make sure that application is suspecned until the debugger is attached.

BTW, what option did you choose in Attach to Node.js/Chrome run configuration - Chrome or Node.js? and what node.js version do you use?

0

It's Node 8.11 so I've selected Chrome or Nodejs > 6.3 instead of Node.js < 8.  In Webstorm I've put in my app's IP on the production host and the port as 9229. 

On my host I'm setting this option on the container --inspect=0.0.0.0:9229.

I still get connection refused. This is also supposed to work over http, correct?

0

should work this way... Does debugging work in Chrome using chrome://inspect, selecting your_remote_ip:9229? see https://nodejs.org/en/docs/guides/debugging-getting-started/#chrome-devtools-55, Option1

0

I'm still getting connection refused.  I just want to confirm that there is nothing my host needs to do or I need to configure on my host other than starting node with those debug port properties.  

 

This is supposed to work over http, right?

0

You need to make sure that your host opens the necessary port so that external traffic can connect...

But note that Node.js docs don't recommend using 0.0.0.0 for debugging for security reasons; ssh tunnelling is the preferred way to establish the connection - see https://nodejs.org/en/docs/guides/debugging-getting-started/#enabling-remote-debugging-scenarios

0

请先登录再写评论。