EADDRNOTAVAIL while using EC2 instance only

旧时模样 提交于 2019-12-11 11:48:07

问题


My node application is listening to port 8080. When I add

app.listen(port,'50.30.217.289');

I can access the application from the browser. But when I replace the IP address with the Elastic IP address of my EC2 instance, I get an error :

EADDRNOTAVAIL

How do I fix this ?


回答1:


What you are trying to do is not how it works in EC2.

The public IP address is mapped to the primary private IP address through network address translation (NAT).

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html

If you examine your network interfaces on the machine, you won't find any public IP addresses on them. The public IP addresses are translated onto the private addresses at the Internet gateway. This is done automatically with no configuration needed, for instances with public IP addresses.

To bind a service to a specific public address, you bind it to the matching private IP address on the instance itself.




回答2:


EADDRNOTAVAIL means your EC2 instance does not have a network interface that has that IP address assigned, so you cannot start listening on it.



来源:https://stackoverflow.com/questions/34711564/eaddrnotavail-while-using-ec2-instance-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!