How debugging remote node app that is hosted on server

Port Forwarding using SSH

This is aslo called SSH Port Tunneling. We will use Putty for SSH Tunneling. So lets get start. 

In order to use port forwarding to connect from your local machine to a port on a remote server, you need to:

  • Choose a port number on your local machine (e.g. 5858 in our case) where PuTTY should listen for incoming connections. 
  • Now, before you start your SSH connection, go to the PuTTY Tunnels panel. Make sure the «Local» radio button is set. Enter the local port (e.g. 5858) number into the «Source port» box. Enter the destination host name and port number into the «Destination» box, separated by a colon (e.g. in our case).
  • Now click the [Add] button. The details of your port forwarding should appear in the list box.

Launch Putty. Different categories will be listed on the left side, click on Connection > SSH > Tunnels.
Under Add new forwarded port:, enter the following information:
Source port: [port on local machine]
Destination: [hostname of ccis machine]:[port on ccis machine]
Click Add. 
It would look like this if I wanted to forward port 5858 on the webserver to 5858 on my local machine:

Clicking Add will add it to the list of forwarded ports:

After setting up the port tunnel, select Session from the category list on the left side.
Enter in the Host Name (or IP Address) field and click the Open button at the bottom right.

Select Yes if prompted with this window. 
And you will be inside your server, then you have to run your node app with debug flag in PuTTY terminal:

node --debug app.js

Then you have to install node-inspector to your local machine:

install node-inspector -g

 And start node-inspector in your local machine:


Now you can open the following url in you Chrome browser and debug remote nodejs application:

It may take sometime to load remote files into your browser.