I just started trying out an Ubuntu 16.04 VM on Azure. A node.js app requires listening to a port 3000 on the network interface assigned with the public IP address so remote clients can connect to it over the internet.
However, the node.js app is throwing the error
Error: bind EADDRNOTAVAIL 13.75.111.31:3000
I have already added an inbound security rule
to the network security group to allow:
- Source: Any
- Protocol: Any
- Source port range: *
- Destination: Any
- Destination port range: 3000
- Action: Allow
and this network security group is assigned to the VM.
Additionally, ifconfig
returns only the private ip address 10.0.0.4
on the interface eth0
and the lo
local loopback. There is no interface found for the public ip address 13.75.111.31
.
How can we fixed this problem? Is something setup wrongly?
Best Answer
The public IP is not available to you directly on your VM. Rather, Azure performs 1:1 NAT between that IP and your machine's private IP. So, just configure your systems to listen on the private IP. Assuming network-level things are configured correctly, it should just work.