Is listening on a port on the localhost of a server the same as listening on that port of the server's public IP address?

I set up a free Amazon EC2 instance in order to use a Node app outside of my localhost environment.

The instance is allocated a public IP address at launch, mine for example being 54.187.31.42. Does this mean that if, within my launched Node program on the EC2, I'm listening for connections at http://localhost:8080, the server is listening for the connections at 54.187.31.42:8080 ?

Or is there more to it than that?


No, listening sockets on localhost (127.0.0.1 or ::1 on IPv6-enabled systems) are only accessible from the very same system they were created on.

To configure a program to listen on all interfaces, you'd usually use 0.0.0.0 or ::. According to a quick Google search this should also be valid for node.js.