Presumably you mean this example:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
The message you would have received like so is Server running at http://127.0.0.1:1337/ - the emphasized part is key here, i.e. the server has been configured to listen on the IP address 127.0.0.1 (aka localhost) only, whereas you are trying to browse it via your elastic IP address.
Accordingly, you can achieve you goal by replacing 127.0.0.1 in the listen()statement with the private/internal IP address which has been assigned to your EC2 instance.
Variations
Alternatively, you could use the public/external DNS name instead, which exhibits a lesser known dynamic IP address resolution depending on the origin of the DNS query, see e.g. Why do I have two IP addresses and two host names?:
The external DNS name (which looks like
ec2-72-44-45-204.compute-1.amazonaws.com) resolves to the public IP
address of the instance outside the Amazon EC2 network and the private
IP address from within Amazon EC2 network.
Finally (as per cyberx86's comment, thanks!), you may be able to omit the optional address parameter altogether (but see below), see server.listen(port, [hostname], [callback]):
If the hostname is omitted, the server will accept connections
directed to any IPv4 address (INADDR_ANY).
Be aware though, that this might not always be the right thing in advanced scenarios, insofar there may be more than one network interface available in fact after the recent introduction of Elastic Network Interfaces (ENI) in the Virtual Private Cloud (VPC), which is giving you the ability to create additional ENIs, and to attach a second ENI to an instance (again, this is within the VPC).