I would like to connect to my node server running in debug mode on AWS (node --debug app.js) from my development machine, and be able to debug my app remotely.
Two quest
One more option to use 0.0.0.0
to listen to request from outside:
node-debug --web-host=0.0.0.0 --cli app.js
and visit this address to debug:
http://<the-domain>:8080/?port=5858
it would be better if HTTP/2 is available since there are lots of small files.
Allow me to present an alternative using node --inspect
. I had the same need, although in a Windows environment, I believe this should work for you.
Remote machine (tested with Node 6.10.2, Windows Server 2012)
node --inspect=0.0.0.0:9229 <appname>.js
Local Machine (tested with Win 10, Chrome 60.0.3112.90)
In Chrome DevTools - Click the vertical ellipsis menu in top right:
<remote-ip>:9229
Screenshots of Steps 1,3,4 below.
This is what worked for me:
--debug
flag.Debugger listening on port DEBUG_PORT
message.8080
, not the DEBUG_PORT
as Andrey Sidorov's answer suggests.SERVER_API:8080/debug?ws=127.0.0.1:8080&port=DEBUG_PORT
in browser an voilà.Node Inspector v0.10.1
And with the help of tepez's answer, the following worked for me (Node Inspector v0.12.2):
On my machine:
ssh -L 8080:127.0.0.1:8080 <username>@<host> -N
On the remote server:
node-debug --cli <appname>
And enter the following address in the browser:
127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858
Forward remote debugger port with ssh from your dev machine
ssh -L 5858:127.0.0.1:5858 ubuntu@some.ec2.host.com
And now you can start node-inspector
as if the debugger is running locally.
You can use node --inspect
too in your remote machine.
node --inspect myapp.js
ssh -L 9229:127.0.0.1:9229 myuser@myserver -N
chrome-devtools://devtools/remote/serve_file/@60cd6e859b9ff284980/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/bef2ae68
Enjoy :)
If you are using pm2
just add this on your ecosystem.js
"apps": [{
"name": "myapp",
"script": "index.js",
"node_args": ["--inspect"],
...