Skip to content

Instantly share code, notes, and snippets.

@ben-bradley
Created July 19, 2021 14:08
Show Gist options
  • Save ben-bradley/fda56566c43434a6acb40b3fead4144a to your computer and use it in GitHub Desktop.
Save ben-bradley/fda56566c43434a6acb40b3fead4144a to your computer and use it in GitHub Desktop.
Remote Debugging Node.js

How to Remotely Debug a Node.js Process

  • Open the Brave/Chrome dev tools - brave://inspect/#devices
  • Click on Open dedicated DevTools for Node
  • Log in to the remote host:
ssh USER@REMOTE_IP
  • Figure out how to add --inspect-brk to the startup for your app
  • Bounce the app with whatever process manager you use
  • Check the logs for a line that looks like this:
Debugger listening on ws://127.0.0.1:9229/df2da178-0e77-4b09-8f61-0e43cda1bc64

Note the port number. Your debugger must have a connection listener on this port!

  • In a new terminal, open the SSH tunnel:
ssh -L 9229:localhost:9229 -N USER@REMOTE_IP
  • The debugger should jump into focus, click the blue 'play' button in the top right to continue starting the app
  • Once the app is started, set breakpoints and begin debugging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment