I have a problem with nodejs remote debugging. I'm using centos on remote server and phpstorm on my PC. When I open putty I type the command:
node --debug-brk=5858 main_server.js,
and get the output:
debugger listening on port 5858.
Next thing I do is go to edit configuration in phpstorm, and choose remotehost:8585
. When I'm trying to connect, it pops up:
connecting to remoteserver:8585
connection refused.
What I have done so far is to add port 8585 and 5858 to centos firewall by adding lines to iptables:
-A cP-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 5858 -j ACCEPT
-A cP-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 8585 -j ACCEPT
After that I tried another solution, because I saw in documentation that I need to set up port forwarding:
yum install balance -yt
balance -df 8585 127.0.0.1.5858
and I tried port forwarding with this command:
iptables -t nat -A PREROUTING -p tcp -m tcp -i eth0 --dport 5858 -j DNAT --to 127.0.0.1:5858
The solutions I tried were:
- https://stackoverflow.com/questions/13752362/node-js-on-virtualbox-centos-machine-no-connection
- https://stackoverflow.com/questions/8445534/how-to-remote-debug-node-js-with-phpstorm.
I also opened ports on my local network router and Windows firewall, but I don't know if that will help or not. What is the correct procedure for enabling nodejs remote debugging on centos server? Which ports do I need to open and where (remote server and LAN)? Do I need port forwarding, and if so, what do I need to do in order to make nodejs remote debugging work?