0

When I listen on port 80 with NodeJS v10 all other machines can access the port but the machine itself cannot. This is very strange, and is the same for loopback and the eth0 IP address. However, it can access port 90 on itself just fine as can the other machines on the network.

I've used a simple hello world app to verify that the NodeJS script is not at fault.

This also occurs in NodeJS 12.13.0, so I don't think Node is the problem at all.

iptables -L says everything is empty with policy ACCEPT.

netstat -tulpn lists no port 80 except the one I'm testing with.

Arlen Beiler
  • 167
  • 9
  • Normally, isn't node suppose to listen on :3000? You then send/proxy to webserver port :80 as needed. You don't mention a web server, or it's config. You sure webserver is delivering the app correctly? – B. Shea Oct 30 '19 at 16:45
  • If using as nodejs as simple server, do you have anything else running on port 80? – B. Shea Oct 30 '19 at 16:51
  • If anything else was running, `netstat -tulpn` should list it, right? – Arlen Beiler Oct 30 '19 at 16:52
  • try `sudo netstat -peanut | grep ":80\ "` without node running. You see a 'LISTEN'? Try again with it running. It should be listening to all interfaces for what you want. Not a specific IP or network. – B. Shea Oct 30 '19 at 17:03

2 Answers2

2

I found this line in /etc/rc.local.

iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 8080

Problem found!

This answer says why the rule did not show up in iptables -L: https://serverfault.com/a/685948/32875.

There are 5 tables (filter,nat,mangle,raw,security). You call iptables -L -t table for each.

Arlen Beiler
  • 167
  • 9
0

It's could be because if you want to use port 80, you need sudo permissions for open it.

jdmorei
  • 71
  • 1