2

I'm trying to open port 843 in my Cent OS 5.2, I added following line to etc\sysconfig\iptables :

-A INPUT -p tcp --dport 843 -j ACCEPT

and then updated my iptables service. I need to listen to that port in my node.js application which is running by root user via sudo node index.js command, but I still get forbidden port error when I try establish a connection through that port.

this is what I get by running sudo iptables -L -v :

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination                     
 2811  238K ACCEPT     tcp  --  any    any     anywhere             anywhere                                tcp dpt:http
  112  6224 ACCEPT     tcp  --  any    any     anywhere             anywhere                                tcp dpt:hbci
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere                                tcp dpt:843
   41  2124 ACCEPT     tcp  --  any    any     anywhere             anywhere                                state NEW tcp multiport dports 5901:5903,6001:6003
13093   13M ACCEPT     all  --  any    any     anywhere             anywhere                                state RELATED,ESTABLISHED
   26  3584 ACCEPT     icmp --  any    any     anywhere             anywhere                        
    0     0 ACCEPT     all  --  lo     any     anywhere             anywhere                        
  109  6404 ACCEPT     tcp  --  any    any     anywhere             anywhere                                state NEW tcp dpt:ssh
 888K   80M REJECT     all  --  any    any     anywhere             anywhere 

and this is outpou of sudo netstat -ptl | grep node:

tcp        0      0 *:843       *:*    LISTEN      12927/node
tcp        0      0 *:http      *:*    LISTEN      12927/node
tcp        0      0 *:10843     *:*    LISTEN      12927/node

and I try to listen to that port in socket.io with this code:

var io          = require('socket.io').listen(
                    843,
                    {   log: false,
                        flashPolicyServer: true,
                        transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-multipart', 'xhr-polling', 'jsonp-polling']
                    }
                );
io.sockets.on('connection', function(socket){
    // my event listeners
});
  • Already opened on Stackoverflow: stackoverflow.com/questions/20065197/… – bgentil Nov 19 '13 at 18:59
  • Sorry didn't saw the "on hold" status for off-topic. Where do you see "forbiden port"? can you activate the socket.io logs and set log level to 3? – bgentil Nov 19 '13 at 19:01
  • 2
    FWIW, your iptables configuration looks correct, and node is obviously listening on 843, so I'm guessing the problem is either internal to node, or SELinux. – fukawi2 Nov 20 '13 at 2:39
  • @bgentil thanks for your help, problem was from client side. a firewall was blocking that port. – Nasser Torabzade Nov 20 '13 at 21:44
1

problem solved. all server configuration was correct, apparently a firewall in client side was blocking that port. so I am switching to sockjs which uses the same port as http server (port 80), thus there is no risk of connection being blocked from client side.

  • A BIG THANKS - SAME ISSUE WITH ME, Client side firewall was restricting to connect with socket at server on 80 port – Rohit Bansal Jul 8 '17 at 13:23

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.