Join us for a live demo on Wed. Dec. 11: Debugging Salesforce Apex Applications with Error Monitoring. Register Today!
December 19th, 2014 • By Cory Virok
Node.js has a built-in debugger that you can start in running processes. To do this, send a
SIGUSR1 signal to the running process and connect a debugger. The one, big caveat here is that the
debugger only listens on the local interface,
The following are instructions for debugging Node.js applications running in your company's private network from your laptop, through a bastion host.
SSH into the production host that is running the Node.js app
prod-host $> kill -s SIGUSR1
prod-host $> ssh -N -q -L :8585:localhost:5858
On your laptop
laptop $> ssh -N -q -L 5858::8585 @
Open PyCharm and create a remote debugging configuration.
127.0.0.1using port 5858, name it and save.
Run the new Debug configuration.
At this point your laptop will have connected to your local SSH tunnel which will be connected to your production host's private network interface which will be tunneled to your production host's local network interface and your Node.js process.
PyCharm → local SSH tunnel → bastion host → production host private network → production host localhost → Node.js
Set some breakpoints in PyCharm and watch as your production process begins waits for you to step through your app.
Note: If you'd rather use the command line instead of PyCharm just run the node debugger from your laptop:
laptop $> node debug localhost:5858
Sometimes PyCharm will just not connect to the running process on your production machine. Try restarting each of the SSH tunnels.
If you haven’t already, signup for a 14-day free trial of Rollbar and let us help you defeat annoying errors in your applications. :-)