0

When I run the following command:

lsof -i:8080

This is the result:

node    32419 root    6u  IPv4 122865       TCP localhost.localdomain:webcache (LISTEN)

That result is different from that of the following command:

lsof -i:80

Result:

nginx   32029  root    6u  IPv4 121546       TCP *:http (LISTEN)
nginx   32030 nginx    6u  IPv4 121546       TCP *:http (LISTEN)

Nginx is : "TCP *", but node's process "localhost.localdomain". What does it mean, localhost.localdomain? Does it means the process can access from localhost only?

I have trouble accessing the node process from another server via 8080 port.

Bill the Lizard
  • 352
  • 1
  • 7
  • 15
augustin
  • 3
  • 1
  • 2
  • If you want to listen to anything in a reverse tunnel, make sure you have `GatewayPorts yes` https://web.archive.org/web/20181019185224/https://www.erol.name/reverse-ssh-tunnel-shows-connection-127-0-0-1-instead-ip/ and https://superuser.com/a/1194856/457084 – Ben Creasy Oct 19 '18 at 18:52

2 Answers2

2

in the first case nginx listens only on the loopback interface; 127.0.0.1 is resolved to localhost.localdomain thru /etc/hosts in the second case nginx listens on all the available interfaces (notice *:http)

so the answer is yes, it can be accessed from the local host only;

you can add "-n" flag to lsof to see ip addresses instead of the names those may be resolved to.

user237419
  • 1,663
  • 8
  • 8
  • so can I change node's process into TCP:* like nginx? – augustin Mar 28 '11 at 10:22
  • yes you can, you have to configure "node" to listen on all available interfaces if this is what you want. so i'm not sure what "node" is. if "node" does not support listener configuration then you can do some tricks from either iptables or ipfw/pf (not sure what your OS is) to redirect the traffic destined for node to localhost – user237419 Mar 28 '11 at 10:28
  • node is nodejs Hello World, example code. http://nodejs.org/ , nothing special configuration, just simple 6 line code. hm... so you mean I have find out the solution in node module~ – augustin Mar 28 '11 at 10:35
  • snip: this piece of code: isten(8124, "127.0.0.1"); put "0.0.0.0" instead of "127.0.0.1" – user237419 Mar 28 '11 at 10:37
  • wow, It works~!!! what's the difference? why 127.0.0.1 doesn't work. anyway, Thank you~ – augustin Mar 28 '11 at 10:44
  • 1
    127.0.0.0/8 is defined by iana to be used for local purposes only. this class will never be routed outside your router (well unless you force it to ;) ) nor the router will accept requests coming to this address. putting it simple, you can't access that ip address from outside your host. "0.0.0.0" means "listen to all the available interfaces on this host" – user237419 Mar 28 '11 at 10:51
1

Port 8080 is just listening locally (on localhost).

Port 80 (shown as http) is listening on ALL bound IP addresses on port 80.

jscott
  • 24,204
  • 8
  • 77
  • 99
Jonathan Ross
  • 2,173
  • 11
  • 14
  • For clarity: you're relatively safe with port 8080 being bound to localhost so there's nothing to worry about. HTH, JR – Jonathan Ross Mar 28 '11 at 10:07
  • jonathan, but I have to connect node's module from another server. but, I can't. That's the real problem~ -_-; – augustin Mar 28 '11 at 10:23