0

I installed a node.js application on an EC2 server under windows at Amazon Web Services (AWS). The application works well in localhost on port 80 but not with the elastic IP address associated with the server instance.

If I add this address as a parameter of the listen function:

app.listen(port,'xxx.xx.xxx.xxx', () => { console.log(App listen on port ${port}!) });

I get the error: Error: listen EADDRNOTAVAIL: address not available xx.xx.xxx.xxx:80

On the other hand, it works well locally if I put the IP address provided by ipconfig

Furthermore, it works perfectly with IIS or an apache server with the elastic ip address or a domaine name

Emmanuel
  • 1
  • 1
  • Due to the way public IP addresses of EC2 instances are NATed in AWS, it is usually recommended to listen to all IP addresses via `app.listen(port, '0.0.0.0')`. – Mark B Feb 23 '23 at 12:49
  • Thanks for your answer. Unfortunately, I have tried your recommendation but it doesn't change anything: I get the same result as with default IP address : no answer from the web site. Any other idea ? – Emmanuel Feb 24 '23 at 05:35
  • Make sure the port is open in the security group. And also make sure the port is open in the Windows firewall. – Mark B Feb 24 '23 at 12:25
  • The port is open because it works very well with IIS or Apache/Wamp64 (which are stopped of course when I try Node.js) – Emmanuel Feb 24 '23 at 20:21

0 Answers0