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 in command:

node --debug-brk=5858 main_server.js,

and the output is:

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 with 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

and tried port forwarding with this command

iptables -t nat -A PREROUTING -p tcp -m tcp -i eth0 --dport 5858 -j DNAT --to

The solutions I tried were: https://stackoverflow.com/questions/13752362/node-js-on-virtualbox-centos-machine-no-connection and 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 I have a good logic. What is detailed procedure for enabling nodejs remote debugging on centos server, which ports do I need to open, where exactly (remote server and LAN), do I need port forwarding, and what I need to do in order to make nodejs remote debugging work?


From your configuration it seems the node debugger is listening on port 5858, but in your phpStorm settings you have 8585.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.